結果

問題 No.1218 Something Like a Theorem
ユーザー tentententen
提出日時 2020-09-07 08:27:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 663 bytes
コンパイル時間 3,118 ms
コンパイル使用メモリ 71,268 KB
実行使用メモリ 56,696 KB
最終ジャッジ日時 2023-08-19 16:24:00
合計ジャッジ時間 6,684 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,780 KB
testcase_01 AC 118 ms
55,980 KB
testcase_02 AC 118 ms
55,952 KB
testcase_03 AC 118 ms
56,052 KB
testcase_04 AC 117 ms
56,240 KB
testcase_05 AC 117 ms
55,956 KB
testcase_06 AC 118 ms
55,704 KB
testcase_07 AC 125 ms
56,124 KB
testcase_08 AC 125 ms
55,984 KB
testcase_09 AC 121 ms
56,188 KB
testcase_10 AC 124 ms
56,696 KB
testcase_11 AC 117 ms
56,556 KB
testcase_12 AC 118 ms
56,216 KB
testcase_13 AC 119 ms
55,768 KB
testcase_14 AC 118 ms
56,052 KB
testcase_15 AC 117 ms
55,504 KB
testcase_16 AC 117 ms
55,984 KB
testcase_17 AC 118 ms
55,728 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