結果

問題 No.917 Make One With GCD
ユーザー AEnAEn
提出日時 2022-11-25 11:04:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 320 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 82,396 KB
実行使用メモリ 63,088 KB
最終ジャッジ日時 2024-04-09 19:58:23
合計ジャッジ時間 2,529 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
63,040 KB
testcase_01 AC 36 ms
54,228 KB
testcase_02 AC 33 ms
53,612 KB
testcase_03 AC 35 ms
53,908 KB
testcase_04 AC 33 ms
54,896 KB
testcase_05 AC 33 ms
55,176 KB
testcase_06 AC 34 ms
54,664 KB
testcase_07 AC 33 ms
54,672 KB
testcase_08 AC 35 ms
55,544 KB
testcase_09 AC 41 ms
62,984 KB
testcase_10 AC 41 ms
63,088 KB
testcase_11 AC 41 ms
62,404 KB
testcase_12 AC 40 ms
62,284 KB
testcase_13 AC 41 ms
63,080 KB
testcase_14 AC 44 ms
62,364 KB
testcase_15 AC 40 ms
61,968 KB
testcase_16 AC 42 ms
61,744 KB
testcase_17 AC 35 ms
54,408 KB
testcase_18 AC 35 ms
54,676 KB
testcase_19 AC 36 ms
54,036 KB
testcase_20 AC 35 ms
54,740 KB
testcase_21 AC 36 ms
54,996 KB
testcase_22 AC 35 ms
55,092 KB
testcase_23 AC 37 ms
54,624 KB
testcase_24 AC 35 ms
54,672 KB
testcase_25 AC 36 ms
55,780 KB
testcase_26 AC 35 ms
54,376 KB
testcase_27 AC 35 ms
55,168 KB
testcase_28 AC 34 ms
54,000 KB
testcase_29 AC 35 ms
54,308 KB
testcase_30 AC 34 ms
54,188 KB
testcase_31 AC 34 ms
54,872 KB
testcase_32 AC 33 ms
53,928 KB
testcase_33 AC 33 ms
54,740 KB
testcase_34 AC 34 ms
54,488 KB
testcase_35 AC 33 ms
53,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
from math import gcd

N = int(input())
a = list(map(int, input().split()))
d = defaultdict(int)
d[a[0]] = 1
for i in range(1,N):
    nex = defaultdict(int)
    nex[a[i]] = 1
    for key in d.keys():
        nex[gcd(a[i],key)]+=d[key]
        nex[key]+=d[key]
    d = nex
print(d[1])

0