2014-2015 ACM-ICPC, NEERC, Moscow Subregional Contest D. Do it Right!

D. Do it Right!
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Given two distinct positive integers A and B, find out if it is possible to find a third positive integer C so that a triangle with the sides ABand C is a right triangle. Remember that a triangle is called a right triangle if one of its angles equals to 90 degrees.

Input

The first line of input contains two positive integers A and B: the lengths of the two given sides (1 ≤ A < B ≤ 100).

Output

Output "YES" if it is possible to find such an integer C, or "NO" otherwise.

Sample test(s)
input
3 4
output
YES
input
1 2
output
NO
Note
  • In the first example, we can take C = 5.
  • In the second example, it is impossible to find an integer C with the required property.

题意:给a,b,找一个c是的a^2+b^2=c^2

分析:a,b如此小,为何不暴力?

 

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <cstdlib>
 4 #include <cmath>
 5 #include <ctime>
 6 #include <iostream>
 7 #include <algorithm>
 8 #include <map>
 9 #include <set>
10 #include <vector>
11 #include <deque>
12 #include <queue>
13 using namespace std;
14 typedef long long LL;
15 typedef double DB;
16 #define Rep(i, n) for(int i = (0); i < (n); i++)
17 #define Repn(i, n) for(int i = (n)-1; i >= 0; i--)
18 #define For(i, s, t) for(int i = (s); i <= (t); i++)
19 #define Ford(i, t, s) for(int i = (t); i >= (s); i--)
20 #define rep(i, s, t) for(int i = (s); i < (t); i++)
21 #define repn(i, s, t) for(int i = (s)-1; i >= (t); i--)
22 #define MIT (2147483647)
23 #define MLL (1000000000000000000LL)
24 #define INF (1000000001)
25 #define mk make_pair
26 #define ft first
27 #define sd second
28 #define clr(x, y) (memset(x, y, sizeof(x)))
29 #define sqr(x) ((x)*(x))
30 #define sz(x) ((int) (x).size())
31 #define puf push_front
32 #define pub push_back
33 #define pof pop_front
34 #define pob pop_back
35 
36 template<class T>
37 inline T Getint()
38 {
39     char Ch = ' ';
40     T Ret = 0;
41     while(!(Ch >= '0' && Ch <= '9')) Ch = getchar();
42     while(Ch >= '0' && Ch <= '9')
43     {
44         Ret = Ret * 10 + Ch - '0';
45         Ch = getchar();
46     }
47     return Ret;
48 }
49 
50 int a, b;
51 
52 inline void Input()
53 {
54     cin >> a >> b;
55 }
56 
57 inline int Sqr(int x)
58 {
59     return x * x;
60 }
61 
62 inline void Solve()
63 {
64     For(i, 1, 250)
65     {
66         int Arr[3];
67         Arr[0] = a * a;
68         Arr[1] = b * b;
69         Arr[2] = i * i;
70         sort(Arr, Arr + 3);
71         if(Arr[0] + Arr[1] == Arr[2])
72         {
73             puts("YES");
74             return;
75         }
76     }
77     puts("NO");
78 }
79 
80 int main() {
81      Input();
82      Solve();
83     return 0;
84 }
View Code

 

posted @ 2015-12-21 15:13  yanzx6  阅读(338)  评论(0编辑  收藏  举报