結果

問題 No.917 Make One With GCD
ユーザー hedwig100hedwig100
提出日時 2020-04-12 15:25:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 824 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 8,928 KB
最終ジャッジ日時 2023-09-06 16:48:06
合計ジャッジ時間 2,302 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
8,812 KB
testcase_01 AC 20 ms
8,876 KB
testcase_02 AC 20 ms
8,844 KB
testcase_03 AC 20 ms
8,860 KB
testcase_04 AC 20 ms
8,888 KB
testcase_05 AC 19 ms
8,888 KB
testcase_06 AC 20 ms
8,748 KB
testcase_07 AC 20 ms
8,744 KB
testcase_08 AC 20 ms
8,744 KB
testcase_09 AC 23 ms
8,748 KB
testcase_10 AC 23 ms
8,816 KB
testcase_11 AC 24 ms
8,816 KB
testcase_12 AC 23 ms
8,844 KB
testcase_13 AC 21 ms
8,760 KB
testcase_14 AC 22 ms
8,868 KB
testcase_15 AC 22 ms
8,828 KB
testcase_16 AC 21 ms
8,772 KB
testcase_17 AC 20 ms
8,928 KB
testcase_18 AC 20 ms
8,784 KB
testcase_19 AC 20 ms
8,748 KB
testcase_20 AC 19 ms
8,852 KB
testcase_21 AC 20 ms
8,748 KB
testcase_22 AC 20 ms
8,780 KB
testcase_23 AC 21 ms
8,928 KB
testcase_24 AC 20 ms
8,780 KB
testcase_25 AC 21 ms
8,788 KB
testcase_26 AC 20 ms
8,836 KB
testcase_27 AC 19 ms
8,832 KB
testcase_28 AC 20 ms
8,852 KB
testcase_29 AC 20 ms
8,840 KB
testcase_30 AC 20 ms
8,748 KB
testcase_31 AC 21 ms
8,780 KB
testcase_32 AC 20 ms
8,748 KB
testcase_33 AC 19 ms
8,792 KB
testcase_34 AC 21 ms
8,844 KB
testcase_35 AC 22 ms
8,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def main():
    n = int(input())
    a = list(map(int,input().split()))
    dpnow = {a[0]:1}
    dpbefore = {a[0]:1}

    for i in range(1,n):
        num = a[i]
        dpbefore = deepcopy(dpnow)
        for g in dpbefore:
            newg = gcd(g,num)
            if newg in dpnow:
                dpnow[newg] += dpbefore[g]
            else:
                dpnow[newg] = dpbefore[g]
        if num in dpnow:
            dpnow[num] += 1
        else:
            dpnow[num] = 1
    
    if 1 in dpnow:
        print(dpnow[1])
    else:
        print(0)

if __name__ == '__main__':
    main()
0