// 不知道对不对 最后没时间改了 就A了43% 这是交卷之后改的 import java.util.Scanner; public class Main {     public static void main(String[] args) {         // TODO Auto-generated method stub         Scanner sc = new Scanner(System.in);         int N = sc.nextInt();         int ans = 0;         for (int a = 1; a <= N; a++) {             for (int b = 1; a >= b && b <= N; b++) {                 for (int c = 1; c <= N; c++) {                     if ((a * a + b * b == c * c) && (c <= N)) {                         if (zhishu(a, b) && zhishu(a, c) && zhishu(b, c)) {                             ans++;                         }                     }                 }             }         }         System.out.println(ans);     }     public static boolean zhishu(int a, int b) {         if (a < b) {             int tmp = a;             a = b;             b = tmp;         }         int c;         while ((c = a % b) != 0) {             a = b;             b = c;         }         return b == 1;     } }
点赞 评论

相关推荐

object3:开始给部分🌸孝子上人生第一课了
点赞 评论 收藏
分享
牛客771574427号:恭喜你,华杰
点赞 评论 收藏
分享
牛客网
牛客企业服务