結果

問題 No.1036 Make One With GCD 2
ユーザー hedwig100hedwig100
提出日時 2020-04-24 23:00:00
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 646 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 197,492 KB
最終ジャッジ日時 2024-04-24 18:14:36
合計ジャッジ時間 31,861 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,017 ms
194,752 KB
testcase_01 AC 1,093 ms
157,956 KB
testcase_02 AC 1,209 ms
159,036 KB
testcase_03 AC 341 ms
100,608 KB
testcase_04 AC 528 ms
115,124 KB
testcase_05 AC 52 ms
60,160 KB
testcase_06 AC 50 ms
60,160 KB
testcase_07 AC 528 ms
112,980 KB
testcase_08 AC 446 ms
101,972 KB
testcase_09 AC 1,171 ms
151,760 KB
testcase_10 AC 1,083 ms
154,112 KB
testcase_11 AC 1,200 ms
152,552 KB
testcase_12 AC 1,136 ms
153,856 KB
testcase_13 AC 1,447 ms
179,648 KB
testcase_14 AC 1,545 ms
188,936 KB
testcase_15 AC 1,413 ms
175,320 KB
testcase_16 AC 1,589 ms
175,464 KB
testcase_17 AC 1,486 ms
178,168 KB
testcase_18 AC 113 ms
78,464 KB
testcase_19 AC 127 ms
78,848 KB
testcase_20 AC 135 ms
78,976 KB
testcase_21 AC 126 ms
78,976 KB
testcase_22 AC 1,405 ms
174,604 KB
testcase_23 AC 992 ms
135,372 KB
testcase_24 AC 1,393 ms
178,060 KB
testcase_25 AC 1,285 ms
162,968 KB
testcase_26 AC 1,328 ms
172,748 KB
testcase_27 AC 49 ms
60,288 KB
testcase_28 AC 47 ms
60,544 KB
testcase_29 AC 49 ms
60,160 KB
testcase_30 AC 48 ms
60,160 KB
testcase_31 AC 57 ms
63,872 KB
testcase_32 AC 70 ms
70,528 KB
testcase_33 AC 50 ms
60,800 KB
testcase_34 AC 60 ms
63,872 KB
testcase_35 AC 46 ms
60,160 KB
testcase_36 AC 48 ms
60,416 KB
testcase_37 AC 47 ms
60,032 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)
    dp2 = defaultdict(int)
    dp1[a[0]] = 1
    for i in range(1,n):
        dp2.clear()
        for k in dp1:
            g = gcd(k,a[i])
            dp2[g] += dp1[k]
        dp2[a[i]] += 1
        dp1 = deepcopy(dp2)
        ans += dp1[1]
    print(ans)
if __name__=='__main__':
    main()

0