結果
問題 | No.800 四平方定理 |
ユーザー | ame |
提出日時 | 2019-03-17 21:46:17 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,290 bytes |
コンパイル時間 | 4,021 ms |
コンパイル使用メモリ | 73,308 KB |
実行使用メモリ | 60,792 KB |
最終ジャッジ日時 | 2023-09-22 04:51:52 |
合計ジャッジ時間 | 7,940 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 157 ms
55,968 KB |
testcase_01 | AC | 171 ms
55,508 KB |
testcase_02 | AC | 162 ms
55,568 KB |
testcase_03 | AC | 165 ms
55,620 KB |
testcase_04 | AC | 159 ms
55,452 KB |
testcase_05 | AC | 170 ms
55,724 KB |
testcase_06 | AC | 182 ms
55,628 KB |
testcase_07 | AC | 144 ms
55,840 KB |
testcase_08 | AC | 141 ms
55,556 KB |
testcase_09 | AC | 175 ms
55,500 KB |
testcase_10 | TLE | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
ソースコード
import java.util.Scanner; class yuki2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int d = sc.nextInt(); long ans = 0; long iti = 0; long ni = 0; long san = 0; for (int i = 1; i <= n; i++) { for (int j = i; j <= n; j++) { for (int k = j; k <= n; k++) { long wa = i * i + j * j + k * k; long sa = wa - d; if (sa < 1) { continue; } else { long b = (long) Math.sqrt((double) sa); if (b * b == sa) { if (b <= n) { if (i == j && j == k) { iti++; } else if (i == j || j == k) { ni++; } else { san++; } } } } } } } ans = iti * 1 + ni * 3 + san * 6; System.out.println(ans); sc.close(); } }