Guest User

Untitled

a guest
Dec 13th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. typedef unsigned char _bool;
  4. #define TRUE 1
  5. #define FALSE 0
  6.  
  7. #define MAXSIZE 1000
  8.  
  9. _bool isRtri(int a, int b , int c){
  10. _bool rtf = FALSE;
  11.  
  12. if(a*a + b*b == c*c) rtf = TRUE;
  13. if(a*a + c*c == b*b) rtf = TRUE;
  14. if(c*c + b*b == c*c) rtf = TRUE;
  15. if(a == 0 || b == 0 || c == 0) rtf = FALSE;
  16. return rtf;
  17. }
  18.  
  19.  
  20. int main (void){
  21. int as = 0;
  22. int bs = 0;
  23. int cs = 0;
  24.  
  25. int triCnt=0;
  26. int sums=0;
  27. int maxcnt[2]={0};
  28.  
  29. for(sums=1 ; sums<=MAXSIZE ; sums++){
  30. for(as = 1 ; as <= MAXSIZE ; as++){
  31. for(bs = 1 ; bs <= MAXSIZE ; bs++){
  32. cs = sums - (as + bs);
  33. if(as + bs + cs >= MAXSIZE || cs<=0) break;
  34. if(isRtri(as,bs,cs) == TRUE){
  35. triCnt++;
  36. }
  37. }
  38. }
  39. if(triCnt != 0){
  40. if(maxcnt[1] <= triCnt/4){
  41. maxcnt[0] = sums;
  42. maxcnt[1] = triCnt/4;
  43. }
  44. triCnt=0;
  45. }
  46. }
  47. printf("%d\n",maxcnt[0] ); /* => 840 */
  48. return 0;
  49. }
Add Comment
Please, Sign In to add comment