結果
問題 | No.1730 GCD on Blackboard in yukicoder |
ユーザー | 👑 Kazun |
提出日時 | 2021-11-05 22:43:20 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 854 ms / 2,000 ms |
コード長 | 1,611 bytes |
コンパイル時間 | 1,326 ms |
コンパイル使用メモリ | 86,508 KB |
実行使用メモリ | 120,616 KB |
最終ジャッジ日時 | 2023-08-07 23:17:53 |
合計ジャッジ時間 | 10,350 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 854 ms
115,192 KB |
testcase_01 | AC | 69 ms
71,040 KB |
testcase_02 | AC | 95 ms
91,508 KB |
testcase_03 | AC | 101 ms
91,920 KB |
testcase_04 | AC | 97 ms
91,672 KB |
testcase_05 | AC | 99 ms
91,692 KB |
testcase_06 | AC | 97 ms
91,452 KB |
testcase_07 | AC | 99 ms
91,920 KB |
testcase_08 | AC | 72 ms
71,060 KB |
testcase_09 | AC | 94 ms
87,452 KB |
testcase_10 | AC | 101 ms
87,696 KB |
testcase_11 | AC | 70 ms
71,140 KB |
testcase_12 | AC | 70 ms
71,344 KB |
testcase_13 | AC | 405 ms
115,128 KB |
testcase_14 | AC | 376 ms
115,196 KB |
testcase_15 | AC | 374 ms
115,048 KB |
testcase_16 | AC | 405 ms
115,204 KB |
testcase_17 | AC | 407 ms
115,072 KB |
testcase_18 | AC | 285 ms
108,496 KB |
testcase_19 | AC | 327 ms
115,116 KB |
testcase_20 | AC | 356 ms
117,304 KB |
testcase_21 | AC | 344 ms
117,396 KB |
testcase_22 | AC | 844 ms
112,952 KB |
testcase_23 | AC | 138 ms
104,556 KB |
testcase_24 | AC | 161 ms
120,616 KB |
testcase_25 | AC | 305 ms
114,772 KB |
ソースコード
def Smallest_Prime_Factor(N): """ 0,1,2,...,N の最小の素因数のリスト (0,1 については 1 にしている) """ if N==0: return [1] N=abs(N) L=list(range(N+1)) L[0]=L[1]=1 x=4 while x<=N: L[x]=2 x+=2 x=9 while x<=N: if L[x]==x: L[x]=3 x+=6 x=5 Flag=0 while x*x<=N: if L[x]==x: y=x*x while y<=N: if L[y]==y: L[y]=x y+=x<<1 x+=2+2*Flag Flag^=1 return L def Faster_Prime_Factorization(N,L): """ Smallest_Prime_Factors(N)で求めたリストを利用して, N を高速素因数分解する. L: Smallest_Prime_Factors(N)で求めたリスト """ N=abs(N) D=[] while N>1: a=L[N] k=0 while L[N]==a: k+=1 N//=a D.append([a,k]) return D def Divisors_from_Prime_Factor(P,sorting=False): X=[1] for p,e in P: q=1 n=len(X) for _ in range(e): q*=p for j in range(n): X.append(X[j]*q) if sorting: X.sort() return X #================================================== N=int(input()) A=list(map(int,input().split())) alpha=max(A) L=Smallest_Prime_Factor(alpha) T=[0]*(alpha+1) for a in A: P=Faster_Prime_Factorization(a,L) for d in Divisors_from_Prime_Factor(P): T[d]+=1 X=[0]*(N+1) for i in range(alpha+1): X[T[i]]=i for i in range(N-1,0,-1): X[i]=max(X[i],X[i+1]) print(*X[:0:-1],sep="\n")