HDU 3903 Trigonometric Function
2016-03-06 19:24
363 查看
Problem Description
Give you a triangle ABC. Get more information in the picture below.
Now, give you 6 integers a, b, c, n, m and k. a, b and c are triangle ABC`s three edges. Can you judge whether the result of the following fraction is rational number?
Input
There are several test cases in the input data.
Each case is just one line with 6 integers -- a, b, c, n, m, k (0< a, b, c, n, m, k < 10^4) separated by spaces. The input data ensures that sin(kC) will not be equal with 0.
Output
Each case output “YES”, if the result of the fraction is rational number, otherwise “NO”.
Sample Input
2
1 1 1 1 1 1
3 4 5 6 7 7
Sample Output
NO
YES
数学题,有结论的,如果cos A是有理数,那么cos nA也是,对于原式,分子一定是有理数,只要验证分母也是就行了。
Give you a triangle ABC. Get more information in the picture below.
Now, give you 6 integers a, b, c, n, m and k. a, b and c are triangle ABC`s three edges. Can you judge whether the result of the following fraction is rational number?
Input
There are several test cases in the input data.
Each case is just one line with 6 integers -- a, b, c, n, m, k (0< a, b, c, n, m, k < 10^4) separated by spaces. The input data ensures that sin(kC) will not be equal with 0.
Output
Each case output “YES”, if the result of the fraction is rational number, otherwise “NO”.
Sample Input
2
1 1 1 1 1 1
3 4 5 6 7 7
Sample Output
NO
YES
数学题,有结论的,如果cos A是有理数,那么cos nA也是,对于原式,分子一定是有理数,只要验证分母也是就行了。
#include<cstdio> #include<string> #include<cstring> #include<vector> #include<iostream> #include<queue> #include<cmath> #include<bitset> #include<algorithm> using namespace std; typedef long long LL; const int INF = 0x7FFFFFFF; const int mod = 1e9 + 7; const int maxn = 3e5 + 10; int a, b, c, n, m, k, T; int main() { scanf("%d", &T); while (T--) { scanf("%d%d%d%d%d%d", &a, &b, &c, &n, &m, &k); LL k = (LL)4 * a*a*b*b - (LL)(a*a + b*b - c*c)*(a*a + b*b - c*c); LL sqr = sqrt(1.0*k); if (sqr*sqr == k) printf("YES\n"); else printf("NO\n"); } return 0; }
相关文章推荐
- 【HDU 5366】The mook jong 详解
- 【HDU 2136】Largest prime factor 详细图解
- HDU 1568
- HDU1290
- HDU1568(Fobonacci公式)
- HDU ACM Step 2.2.2 Joseph(约瑟夫环问题)
- HDU 1405
- HDU 1297
- hdu 1205
- hdu 2087
- hdu 1016
- HDU 4898 The Revenge of the Princess’ Knight ( 2014 Multi-University Training Contest 4 )
- HDU 5592 ZYB's Premutation 线段树(查找动态区间第K大)
- HDU 5240 Exam (好水的题)
- HDU5237 Base64 大模拟
- HDU 1000
- HDU 1001
- 2015-11-11 hdu新生赛 A题(AC)
- 2015-11-11 hdu新生赛 C题(结束后一发AC)
- 2015-11-11 hdu新生赛 E题(结束后一发AC)