304A.md (1375B)
1 Source: https://codeforces.com/problemset/problem/304/A 2 3 A. Pythagorean Theorem II 4 5 time limit per test 6 7 3 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 stdin 16 17 output 18 19 stdout 20 21 In mathematics, the Pythagorean theorem — is a relation in Euclidean geometry among the three sides of a right-angled triangle. In terms of areas, it states: 22 23 In any right-angled triangle, the area of the square whose side is the hypotenuse (the side opposite the right angle) is equal to the sum of the areas of the squares whose sides are the two legs (the two sides that meet at a right angle). 24 25 The theorem can be written as an equation relating the lengths of the sides *a*, *b* and *c*, often called the Pythagorean equation: 26 27 *a*2 + *b*2 = *c*2 28 29 where *c* represents the length of the hypotenuse, and *a* and *b* represent the lengths of the other two sides. 30 31  32 33 Given *n*, your task is to count how many right-angled triangles with side-lengths *a*, *b* and *c* that satisfied an inequality 1 ≤ *a* ≤ *b* ≤ *c* ≤ *n*. 34 35 Input 36 37 The only line contains one integer *n* (1 ≤ *n* ≤ 104) as we mentioned above. 38 39 Output 40 41 Print a single integer — the answer to the problem. 42 43 Examples 44 45 Input 46 47 ``` 48 5 49 ``` 50 51 Output 52 53 ``` 54 1 55 ``` 56 57 Input 58 59 ``` 60 74 61 ``` 62 63 Output 64 65 ``` 66 35 67 ```