結果

問題 No.1593 Perfect Distance
ユーザー kona0001kona0001
提出日時 2021-07-09 22:40:36
言語 Ruby
(3.3.0)
結果
AC  
実行時間 154 ms / 2,000 ms
コード長 179 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 11,444 KB
実行使用メモリ 24,940 KB
最終ジャッジ日時 2023-09-14 09:58:42
合計ジャッジ時間 3,143 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
15,056 KB
testcase_01 AC 82 ms
15,272 KB
testcase_02 AC 83 ms
15,344 KB
testcase_03 AC 82 ms
15,184 KB
testcase_04 AC 83 ms
15,144 KB
testcase_05 AC 83 ms
15,136 KB
testcase_06 AC 84 ms
15,264 KB
testcase_07 AC 85 ms
15,084 KB
testcase_08 AC 84 ms
15,312 KB
testcase_09 AC 85 ms
15,652 KB
testcase_10 AC 90 ms
16,400 KB
testcase_11 AC 95 ms
17,748 KB
testcase_12 AC 108 ms
20,120 KB
testcase_13 AC 107 ms
20,092 KB
testcase_14 AC 113 ms
20,104 KB
testcase_15 AC 130 ms
24,832 KB
testcase_16 AC 154 ms
24,940 KB
testcase_17 AC 82 ms
15,128 KB
testcase_18 AC 84 ms
15,272 KB
testcase_19 AC 83 ms
15,280 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