This question took nearly an hour, and some situations such as incorrect thinking and out-of-the-boundary occurred successively. After various processing, the AC finally
Start with the formula --
Cos (nA + mB) = cos (nA) cos (mB)-sin (nA) sin (mB)
According to the doubling formula, any n times of sin (nA), cos (nA), tan (nA) can be converted into sin (A), cos () the polynomial form of tan ()
According to the cosine formula, cos (A) = (B * B + c * c-a * a)/(2 * B * c), Because a, B, and c are rational numbers, so the cosine of the three angles is rational.
Conclusion We only need to prove that sin (A), sin (B) and sin (C) are rational numbers.
By sin ^ 2 (A) + cos ^ 2 (A) = 1, we can infer whether sin (A) is A rational number.
At first, I multiplied both sides of the equation by 4 * a * B * c at the same time, and found that the result was too large, exceeding long, later, we thought that we only need to multiply the cos denominator, so that the result can be within the long range.
#include <stdio.h> #include <math.h> #define LL long long int main() { LL T; LL a,b,c,n,m,k; scanf("%I64d",&T); while(T--) { scanf("%I64d%I64d%I64d%I64d%I64d%I64d",&a,&b,&c,&n,&m,&k); LL A=4*b*b*c*c-(b*b+c*c-a*a)*(b*b+c*c-a*a); LL B=4*a*a*c*c-(a*a+c*c-b*b)*(a*a+c*c-b*b); LL C=4*a*a*b*b-(a*a+b*b-c*c)*(a*a+b*b-c*c); LL AA=sqrt(A); LL BB=sqrt(B); LL CC=sqrt(C); if(AA*AA==A&&BB*BB==B&&CC*CC==C) printf("YES\n"); else printf("NO\n"); } return 0; }