結果
問題 | No.2449 square_permutation |
ユーザー | siman |
提出日時 | 2023-09-01 15:20:31 |
言語 | Ruby (3.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 353 bytes |
コンパイル時間 | 516 ms |
コンパイル使用メモリ | 11,296 KB |
実行使用メモリ | 21,380 KB |
最終ジャッジ日時 | 2023-09-01 15:20:37 |
合計ジャッジ時間 | 5,625 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 75 ms
19,560 KB |
testcase_01 | AC | 83 ms
15,120 KB |
testcase_02 | AC | 78 ms
15,124 KB |
testcase_03 | AC | 78 ms
15,124 KB |
testcase_04 | AC | 89 ms
15,036 KB |
testcase_05 | AC | 332 ms
15,104 KB |
testcase_06 | TLE | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
コンパイルメッセージ
Syntax OK
ソースコード
N = gets.to_i ans = [*0..N] checked = Hash.new(false) 1.upto(N) do |i| n = 1 max_v = 0 while n * i <= N * N && n <= N x = n * i if Math.sqrt(x).to_i ** 2 == x max_v = n if !checked[n] end n += 1 end checked[max_v] = true if max_v > i ans[i], ans[max_v] = ans[max_v], ans[i] end end puts ans[1..].join(' ')