結果

問題 No.917 Make One With GCD
コンテスト
ユーザー ああ
提出日時 2026-05-14 21:29:56
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 455 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 312 ms
コンパイル使用メモリ 84,736 KB
実行使用メモリ 65,024 KB
最終ジャッジ日時 2026-05-14 21:30:06
合計ジャッジ時間 2,680 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def gcd(x,y):
    while x%y:
        x,y=y,x%y
    return y 

n=int(input())
a=list(map(int,input().split()));s=set()
for i in a:
    for j in range(1,int(i**0.5)+1):
        if i%j:
            continue
        s.add(j)
        s.add(i//j)
x={};p=0
m=len(s)
s=list(s);s.sort()
for i in s:
    x[i]=p;p+=1
dp=[0]*m
for i in a:
    for j in range(m):
        if not dp[j]:
            continue
        dp[x[gcd(i,s[j])]]+=dp[j]
    dp[x[i]]+=1
print(dp[0])
0