結果

問題 No.1593 Perfect Distance
ユーザー kona0001kona0001
提出日時 2021-07-09 22:39:16
言語 Ruby
(3.1.1p18 )
結果
AC  
実行時間 130 ms / 2,000 ms
コード長 179 bytes
コンパイル時間 128 ms
使用メモリ 23,616 KB
最終ジャッジ日時 2023-02-02 00:39:16
合計ジャッジ時間 3,337 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 72 ms
13,828 KB
testcase_01 AC 71 ms
13,980 KB
testcase_02 AC 71 ms
14,000 KB
testcase_03 AC 72 ms
13,836 KB
testcase_04 AC 71 ms
13,728 KB
testcase_05 AC 71 ms
13,864 KB
testcase_06 AC 71 ms
13,828 KB
testcase_07 AC 71 ms
13,900 KB
testcase_08 AC 71 ms
13,832 KB
testcase_09 AC 74 ms
14,280 KB
testcase_10 AC 78 ms
15,140 KB
testcase_11 AC 84 ms
16,352 KB
testcase_12 AC 93 ms
18,792 KB
testcase_13 AC 94 ms
18,956 KB
testcase_14 AC 97 ms
18,720 KB
testcase_15 AC 113 ms
23,616 KB
testcase_16 AC 130 ms
23,436 KB
testcase_17 AC 73 ms
13,796 KB
testcase_18 AC 72 ms
13,940 KB
testcase_19 AC 72 ms
13,944 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