Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- MIPT, task # 006
- "Three Squares"
- 12.09.2011
- */
- #include <stdio.h>
- #include <math.h>
- #define SQR(a) ((a) * (a))
- int main ()
- {
- int n, i;
- scanf ("%d", &n);
- int ans = 0;
- while (n >= 0) {
- char found = 0;
- int a, b, c;
- for (a = 0; SQR (a) <= n && !found; ++a) {
- for (b = 0; SQR (a) + SQR (b) <= n && !found; ++b) {
- c = n - SQR (a) - SQR(b);
- float sqrt_c = sqrt(c);
- if (sqrt_c == (int)(sqrt_c)) {
- found = 1;
- //printf ("%d + %d + %d = %d\n", SQR (a), SQR (b), SQR (c), n);
- }
- }
- }
- if (!found) {
- ++ans;
- }
- --n;
- }
- printf ("%d", ans);
- return 0;
- }
Add Comment
Please, Sign In to add comment