結果

問題 No.1218 Something Like a Theorem
ユーザー tentententen
提出日時 2020-09-07 08:27:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 663 bytes
コンパイル時間 2,362 ms
コンパイル使用メモリ 74,176 KB
実行使用メモリ 41,404 KB
最終ジャッジ日時 2024-05-06 23:22:49
合計ジャッジ時間 5,599 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,236 KB
testcase_01 AC 134 ms
41,272 KB
testcase_02 AC 131 ms
41,156 KB
testcase_03 AC 132 ms
41,112 KB
testcase_04 AC 132 ms
41,272 KB
testcase_05 AC 134 ms
41,308 KB
testcase_06 AC 132 ms
41,312 KB
testcase_07 AC 136 ms
41,404 KB
testcase_08 AC 142 ms
41,236 KB
testcase_09 AC 124 ms
39,980 KB
testcase_10 AC 126 ms
40,088 KB
testcase_11 AC 132 ms
41,376 KB
testcase_12 AC 137 ms
41,352 KB
testcase_13 AC 119 ms
40,260 KB
testcase_14 AC 130 ms
41,252 KB
testcase_15 AC 131 ms
41,028 KB
testcase_16 AC 120 ms
40,272 KB
testcase_17 AC 133 ms
41,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int z = sc.nextInt();
    	boolean flag = false;
    	if (n == 1) {
    	    flag = (z != 1);
    	} else if (n == 2) {
    	    for (int i = 1; i < z; i++) {
    	        for (int j = i; i * i + j * j <= z * z; j++) {
    	            if (i * i + j * j == z * z) {
    	                flag = true;
    	            }
    	        }
    	    }
    	} else {
    	    flag = false;
    	}
    	if (flag) {
    	    System.out.println("Yes");
    	} else {
    	    System.out.println("No");
    	}
    }
}
0