結果

問題 No.1036 Make One With GCD 2
ユーザー hedwig100hedwig100
提出日時 2020-04-24 23:01:49
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 620 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 197,492 KB
最終ジャッジ日時 2024-04-25 01:15:03
合計ジャッジ時間 18,051 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 329 ms
193,868 KB
testcase_01 AC 347 ms
155,680 KB
testcase_02 AC 398 ms
158,652 KB
testcase_03 AC 111 ms
101,888 KB
testcase_04 AC 152 ms
113,336 KB
testcase_05 AC 47 ms
59,776 KB
testcase_06 AC 48 ms
59,904 KB
testcase_07 AC 223 ms
111,204 KB
testcase_08 AC 180 ms
100,572 KB
testcase_09 AC 498 ms
150,612 KB
testcase_10 AC 460 ms
154,624 KB
testcase_11 AC 489 ms
151,164 KB
testcase_12 AC 438 ms
153,984 KB
testcase_13 AC 676 ms
179,148 KB
testcase_14 AC 678 ms
187,844 KB
testcase_15 AC 648 ms
174,944 KB
testcase_16 AC 637 ms
175,232 KB
testcase_17 AC 656 ms
177,676 KB
testcase_18 AC 65 ms
68,352 KB
testcase_19 AC 69 ms
69,376 KB
testcase_20 AC 66 ms
70,784 KB
testcase_21 AC 66 ms
70,912 KB
testcase_22 AC 634 ms
174,872 KB
testcase_23 AC 483 ms
134,336 KB
testcase_24 AC 638 ms
177,544 KB
testcase_25 AC 620 ms
162,224 KB
testcase_26 AC 617 ms
172,376 KB
testcase_27 AC 54 ms
59,904 KB
testcase_28 AC 52 ms
60,160 KB
testcase_29 AC 46 ms
60,288 KB
testcase_30 AC 48 ms
60,288 KB
testcase_31 AC 49 ms
60,544 KB
testcase_32 AC 49 ms
61,184 KB
testcase_33 AC 48 ms
60,544 KB
testcase_34 AC 50 ms
60,928 KB
testcase_35 AC 46 ms
60,032 KB
testcase_36 AC 46 ms
60,416 KB
testcase_37 AC 45 ms
59,904 KB
testcase_38 TLE -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 10 ** 9
MOD = 10 **9 + 7
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from math import gcd
from collections import defaultdict
from copy import deepcopy

def main():
    n = int(input())
    a = list(map(int,input().split()))

    if a[0] == 1:
        ans = 1
    else:
        ans = 0

    dp1 = defaultdict(int)
    dp1[a[0]] = 1
    for i in range(1,n):
        dp2 = defaultdict(int)
        for k in dp1:
            g = gcd(k,a[i])
            dp2[g] += dp1[k]
        dp2[a[i]] += 1
        dp1 = dp2
        ans += dp1[1]
    print(ans)
if __name__=='__main__':
    main()

0