結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 #

#!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