結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー gr1msl3ygr1msl3y
提出日時 2021-11-05 22:53:36
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,008 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 136,516 KB
最終ジャッジ日時 2024-04-24 06:52:54
合計ジャッジ時間 7,032 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
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 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
M = 10**6
# M=20
K = 20
fact = [1]*(M+1)
isprime = []
for i in range(2, M+1):
    if fact[i] > 1:
        continue
    isprime.append(i)
    for j in range(i*2, M+1, i):
        if fact[j] == 1:
            fact[j] = j//i

count = {p: [0]*(K+1) for p in isprime}
for i, a in enumerate(A):
    f = defaultdict(int)
    while a > 1:
        q = a//fact[a]
        f[q] += 1
        a = fact[a]
    for p in f:
        count[p][f[p]] |= 1 << i

for p in count:
    for i in range(K, 0, -1):
        count[p][i-1] |= count[p][i]
    count[p][0] = (1 << N)-1

ans = [0]*(N+1)
ans[0] = 1
for i in range(2, M+1):
    f = defaultdict(int)
    a = i
    while a > 1:
        q = a//fact[a]
        f[q] += 1
        a = fact[a]
    ct = (1 << N)-1
    for p in f:
        ct &= count[p][f[p]]
    c = str(bin(ct)).count('1')
    ans[N-c] = i

for i in range(N-1):
    ans[i+1] = max(ans[i], ans[i+1])
print(*ans[:-1], sep='\n')
0