結果

問題 No.1731 Product of Subsequence
ユーザー vwxyzvwxyz
提出日時 2023-11-28 21:22:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,401 ms / 2,000 ms
コード長 1,088 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 102,368 KB
最終ジャッジ日時 2023-11-28 21:22:41
合計ジャッジ時間 18,235 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,118 ms
101,600 KB
testcase_01 AC 145 ms
89,056 KB
testcase_02 AC 137 ms
89,056 KB
testcase_03 AC 136 ms
89,056 KB
testcase_04 AC 137 ms
89,056 KB
testcase_05 AC 143 ms
89,952 KB
testcase_06 AC 144 ms
89,952 KB
testcase_07 AC 140 ms
89,056 KB
testcase_08 AC 180 ms
90,208 KB
testcase_09 AC 158 ms
90,208 KB
testcase_10 AC 1,379 ms
102,368 KB
testcase_11 AC 1,176 ms
96,096 KB
testcase_12 AC 152 ms
90,208 KB
testcase_13 AC 202 ms
90,720 KB
testcase_14 AC 1,063 ms
96,992 KB
testcase_15 AC 138 ms
89,056 KB
testcase_16 AC 139 ms
89,056 KB
testcase_17 AC 138 ms
89,056 KB
testcase_18 AC 970 ms
97,760 KB
testcase_19 AC 190 ms
90,592 KB
testcase_20 AC 822 ms
95,456 KB
testcase_21 AC 1,401 ms
100,192 KB
testcase_22 AC 152 ms
90,208 KB
testcase_23 AC 156 ms
90,208 KB
testcase_24 AC 185 ms
90,336 KB
testcase_25 AC 175 ms
90,336 KB
testcase_26 AC 423 ms
90,848 KB
testcase_27 AC 464 ms
90,848 KB
testcase_28 AC 761 ms
92,640 KB
testcase_29 AC 406 ms
90,848 KB
testcase_30 AC 1,191 ms
97,632 KB
testcase_31 AC 152 ms
90,208 KB
testcase_32 AC 150 ms
90,208 KB
testcase_33 AC 150 ms
90,208 KB
testcase_34 AC 272 ms
90,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
import time
from collections import Counter,deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
    if heap and item < heap[0]:
        item, heap[0] = heap[0], item
        heapq._siftup_max(heap, 0)
    return item
from math import gcd as GCD
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines
write=sys.stdout.write
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')
#sys.set_int_max_str_digits(10**9)

N,K=map(int,readline().split())
A=list(map(int,readline().split()))
mod=10**9+7
dp=defaultdict(int)
for a in A:
    prev=dp
    dp=defaultdict(int)
    for aa,c in prev.items():
        dp[aa]+=c
        dp[GCD(aa*a,K)]+=c
    dp[GCD(a,K)]+=1
    for aa in dp:
        dp[aa]%=mod
ans=dp[K]
print(ans)
0