diff options
| author | Reiner Herrmann <reiner@reiner-h.de> | 2014-08-31 20:21:45 +0200 |
|---|---|---|
| committer | Reiner Herrmann <reiner@reiner-h.de> | 2014-08-31 20:35:09 +0200 |
| commit | 95341b61b030c9e1290f3b326cb7ec584f543aea (patch) | |
| tree | 852386fa04d32eb859bca11c0eff7b5ef9e50f00 /039.c | |
| parent | 571164d977f91925c4c76a292f74f5f93d09ae23 (diff) | |
Diffstat (limited to '039.c')
| -rw-r--r-- | 039.c | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -0,0 +1,37 @@ + +int solutions(int p) +{ + int solution = 0; + int a, b, c; + + for(a=0; a<p/2; a++) + for(b=0; b<p-a; b++) + { + c = p - a - b; + if(a*a + b*b == c*c) + solution++; + } + return solution; +} + +int main() +{ + int max_solutions = 0; + int max_p = 0; + int p; + + for(p=3; p<=1000; p++) + { + int n = solutions(p); + if(n > max_solutions) + { + max_solutions = n; + max_p = p; + } + } + + printf("%d\n", max_p); + + return 0; +} + |
