結果

問題 No.2392 二平方和
ユーザー ks2mks2m
提出日時 2023-07-28 22:32:09
言語 Java21
(openjdk 21)
結果
AC  
実行時間 166 ms / 2,000 ms
コード長 468 bytes
コンパイル時間 2,479 ms
コンパイル使用メモリ 74,764 KB
実行使用メモリ 42,220 KB
最終ジャッジ日時 2024-04-16 06:29:22
合計ジャッジ時間 7,060 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
40,268 KB
testcase_01 AC 134 ms
41,232 KB
testcase_02 AC 130 ms
41,352 KB
testcase_03 AC 134 ms
41,216 KB
testcase_04 AC 135 ms
41,132 KB
testcase_05 AC 133 ms
41,372 KB
testcase_06 AC 129 ms
40,976 KB
testcase_07 AC 137 ms
41,548 KB
testcase_08 AC 119 ms
40,184 KB
testcase_09 AC 120 ms
40,024 KB
testcase_10 AC 131 ms
41,316 KB
testcase_11 AC 134 ms
41,116 KB
testcase_12 AC 120 ms
40,044 KB
testcase_13 AC 132 ms
41,428 KB
testcase_14 AC 133 ms
41,144 KB
testcase_15 AC 133 ms
41,328 KB
testcase_16 AC 131 ms
41,348 KB
testcase_17 AC 133 ms
41,328 KB
testcase_18 AC 136 ms
41,284 KB
testcase_19 AC 137 ms
41,584 KB
testcase_20 AC 159 ms
42,104 KB
testcase_21 AC 160 ms
41,988 KB
testcase_22 AC 161 ms
42,164 KB
testcase_23 AC 162 ms
42,220 KB
testcase_24 AC 166 ms
41,916 KB
testcase_25 AC 149 ms
41,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		sc.close();

		Set<Integer> set = new HashSet<>();
		for (int i = 1; i * i <= p; i++) {
			set.add(i * i);
		}

		for (int e : set) {
			if (set.contains(p - e)) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}
0