結果

問題 No.1730 GCD on Blackboard in yukicoder
ユーザー dn6049949dn6049949
提出日時 2021-11-05 22:05:11
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,051 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 82,124 KB
実行使用メモリ 115,060 KB
最終ジャッジ日時 2024-11-06 12:56:17
合計ジャッジ時間 7,258 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 2
other TLE * 1 -- * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def IR(n):
    return [I() for _ in range(n)]
def LIR(n):
    return [LI() for _ in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def f(n):
        i = 2
        res = {1,n}
        while i*i <= n:
            if n%i == 0:
                res.add(i)
                res.add(n//i)
            i += 1
        return res

    n = I()
    a = LI()
    m = max(a)+1
    cnt = [0]*m
    for x in a:
        for i in f(x):
            cnt[i] += 1
    ans = [0]*n
    for i in range(m)[::-1]:
        ci = cnt[i]-1
        if ci >= 0 and not ans[ci]:
            ans[ci] = i
    for i in range(n-1)[::-1]:
        ans[i] = max(ans[i],ans[i+1])
    for i in ans[::-1]:
        print(i)
    return


if __name__ == "__main__":
    solve()
0