結果

問題 No.152 貯金箱の消失
ユーザー uafr_csuafr_cs
提出日時 2015-09-01 02:42:46
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 912 bytes
コンパイル時間 2,217 ms
コンパイル使用メモリ 76,172 KB
実行使用メモリ 58,028 KB
最終ジャッジ日時 2023-09-25 21:33:18
合計ジャッジ時間 12,755 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 718 ms
55,584 KB
testcase_01 AC 719 ms
55,688 KB
testcase_02 AC 722 ms
55,704 KB
testcase_03 AC 719 ms
55,696 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;


public class Main {
	
	public static int gcd(int a, int b){
		return b == 0 ? a : gcd(b, a % b);
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		final long L = sc.nextLong();
		
		int count = 0;
		
		for(int a = 1; a <= 10000; a++){
			for(int b = a + 1; b <= 10000; b++){
				final int c = (int)(Math.floor(Math.sqrt(a * a + b * b)));
				
				if(a * a + b * b != c * c){ continue; }
				
				final int gcd = gcd(a, gcd(b, c));
				final int sum = a + b + c;
				
				if(gcd != 1){ continue; }
				if(sum * 4L > L){ continue; }
				
				//System.out.println(a + " " +  b + " " + c + " " + sum);
				count++;
			}
		}
		
		System.out.println(count);
	}
	
}
0