結果

問題 No.1218 Something Like a Theorem
ユーザー TANIGUCHI KousukeTANIGUCHI Kousuke
提出日時 2020-09-10 12:41:07
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 233 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 11,564 KB
実行使用メモリ 15,344 KB
最終ジャッジ日時 2023-08-24 18:13:50
合計ジャッジ時間 2,887 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,144 KB
testcase_01 AC 78 ms
15,124 KB
testcase_02 WA -
testcase_03 AC 79 ms
15,084 KB
testcase_04 AC 83 ms
15,296 KB
testcase_05 RE -
testcase_06 WA -
testcase_07 AC 78 ms
15,344 KB
testcase_08 AC 78 ms
15,300 KB
testcase_09 WA -
testcase_10 AC 79 ms
15,148 KB
testcase_11 WA -
testcase_12 AC 79 ms
15,260 KB
testcase_13 AC 77 ms
15,292 KB
testcase_14 AC 78 ms
15,320 KB
testcase_15 AC 81 ms
15,084 KB
testcase_16 AC 77 ms
15,124 KB
testcase_17 AC 77 ms
15,336 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, z = gets.split.map(&:to_i)
dp2 = Array.new(1010){|i| i * i }
if n >= 3
  puts :No
else
  ans = (1 .. z).find do |x|
    y2 = z * z - x * x
    y = dp2.bsearch_index{|v| v >= y2 }
    dp2[y] == y2
  end
  puts ans ? :Yes : :No
end
0