HDU 3903-Trigonometric Function

Source: Internet
Author: User

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;  }  

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.