結果

問題 No.2449 square_permutation
ユーザー FromBooskaFromBooska
提出日時 2023-09-01 11:41:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 490 bytes
コンパイル時間 558 ms
コンパイル使用メモリ 87,292 KB
実行使用メモリ 93,896 KB
最終ジャッジ日時 2023-09-01 11:41:12
合計ジャッジ時間 6,141 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,468 KB
testcase_01 AC 67 ms
71,348 KB
testcase_02 AC 69 ms
71,424 KB
testcase_03 AC 69 ms
71,332 KB
testcase_04 AC 68 ms
71,468 KB
testcase_05 AC 93 ms
77,012 KB
testcase_06 AC 108 ms
82,500 KB
testcase_07 AC 111 ms
83,388 KB
testcase_08 AC 109 ms
84,284 KB
testcase_09 AC 111 ms
85,268 KB
testcase_10 AC 123 ms
88,236 KB
testcase_11 AC 125 ms
89,244 KB
testcase_12 AC 127 ms
90,132 KB
testcase_13 AC 164 ms
93,760 KB
testcase_14 AC 139 ms
93,836 KB
testcase_15 AC 139 ms
93,640 KB
testcase_16 AC 140 ms
93,556 KB
testcase_17 AC 139 ms
93,896 KB
testcase_18 AC 142 ms
92,216 KB
testcase_19 AC 164 ms
93,360 KB
testcase_20 AC 147 ms
93,772 KB
testcase_21 AC 147 ms
93,816 KB
testcase_22 AC 72 ms
71,600 KB
testcase_23 AC 149 ms
93,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
pos = [-1]*(N+1)
for n in range(1, N+1):
    if pos[n] != -1:
        continue
    
    if n > N/2 and pos[n] == -1:
        pos[n] = n
        continue
    candidates = []
    for j in range(1, N+1):
        if n*j*j > N:
            break
        if pos[n*j*j] == -1:
            candidates.append(n*j*j)
    L = len(candidates)
    for l in range(L):
        pos[candidates[l]] = candidates[L-l-1]
    #print('n', n, 'candidates', candidates, 'pos', pos)
print(*pos[1:])
0