結果

問題 No.917 Make One With GCD
ユーザー kiccho1101kiccho1101
提出日時 2022-04-24 11:22:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 472 bytes
コンパイル時間 689 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 78,912 KB
最終ジャッジ日時 2023-09-08 04:27:16
合計ジャッジ時間 6,548 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
77,660 KB
testcase_01 AC 88 ms
71,912 KB
testcase_02 AC 89 ms
71,856 KB
testcase_03 AC 89 ms
71,520 KB
testcase_04 AC 93 ms
71,832 KB
testcase_05 AC 89 ms
71,372 KB
testcase_06 AC 99 ms
77,756 KB
testcase_07 AC 105 ms
77,600 KB
testcase_08 AC 91 ms
71,704 KB
testcase_09 AC 117 ms
77,452 KB
testcase_10 AC 123 ms
77,720 KB
testcase_11 AC 123 ms
77,716 KB
testcase_12 AC 123 ms
77,588 KB
testcase_13 AC 117 ms
77,684 KB
testcase_14 AC 119 ms
77,520 KB
testcase_15 AC 137 ms
78,912 KB
testcase_16 AC 117 ms
77,576 KB
testcase_17 AC 88 ms
71,704 KB
testcase_18 AC 107 ms
77,592 KB
testcase_19 AC 89 ms
71,728 KB
testcase_20 AC 88 ms
71,704 KB
testcase_21 AC 98 ms
76,492 KB
testcase_22 AC 90 ms
71,916 KB
testcase_23 AC 113 ms
77,384 KB
testcase_24 AC 100 ms
76,628 KB
testcase_25 AC 112 ms
77,664 KB
testcase_26 AC 91 ms
71,776 KB
testcase_27 AC 90 ms
71,616 KB
testcase_28 AC 89 ms
71,328 KB
testcase_29 AC 89 ms
71,836 KB
testcase_30 AC 90 ms
71,916 KB
testcase_31 AC 90 ms
71,616 KB
testcase_32 AC 90 ms
71,704 KB
testcase_33 AC 88 ms
71,916 KB
testcase_34 AC 91 ms
71,564 KB
testcase_35 AC 89 ms
71,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict


def gcd(a, b):
    return a if b == 0 else gcd(b, a % b)


N = int(input())
A = list(map(int, input().split()))


# dp[i][j]: i番目までで最大公約数がjになる場合の数
dp = [defaultdict(int) for _ in range(N + 1)]


for i in range(N):
    dp[i][A[i]] += 1
    for j in range(i + 1, N):
        for k in dp[i].keys():
            dp[j][gcd(k, A[j])] += dp[i][k]
ans = 0
for i in range(N):
    ans += dp[i][1]
print(ans)
0