結果

問題 No.1593 Perfect Distance
ユーザー kona0001kona0001
提出日時 2021-07-09 22:39:16
言語 Ruby
(3.3.0)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 179 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 11,508 KB
実行使用メモリ 24,948 KB
最終ジャッジ日時 2023-09-14 09:57:04
合計ジャッジ時間 3,241 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,180 KB
testcase_01 AC 81 ms
15,288 KB
testcase_02 AC 83 ms
15,316 KB
testcase_03 AC 82 ms
15,084 KB
testcase_04 AC 81 ms
15,136 KB
testcase_05 AC 82 ms
15,284 KB
testcase_06 AC 81 ms
15,076 KB
testcase_07 AC 81 ms
15,136 KB
testcase_08 AC 80 ms
15,080 KB
testcase_09 AC 82 ms
15,772 KB
testcase_10 AC 87 ms
16,208 KB
testcase_11 AC 93 ms
17,744 KB
testcase_12 AC 104 ms
20,072 KB
testcase_13 AC 103 ms
20,204 KB
testcase_14 AC 108 ms
20,128 KB
testcase_15 AC 126 ms
24,948 KB
testcase_16 AC 148 ms
24,740 KB
testcase_17 AC 81 ms
15,256 KB
testcase_18 AC 81 ms
15,276 KB
testcase_19 AC 82 ms
15,324 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
heiho = Hash.new(0)
x = 1
while x*x <= n*n
  heiho[x*x] = 1
  x += 1
end

cnt = 0
x = 1
while x <= n
  y2 = n*n - x*x
  cnt += 1 if heiho[y2] == 1
  x += 1
end
p cnt
0