Created
September 26, 2017 05:12
-
-
Save jakab922/17789a03f57da77f5b18f4fdbeb90f61 to your computer and use it in GitHub Desktop.
C1/2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fractions import gcd | |
from collections import defaultdict as dd | |
n, k = map(int, raw_input().strip().split()) | |
ais = filter(lambda x: x != 0, map(int, raw_input().strip().split())) | |
n = len(ais) | |
mod = 10 ** 9 + 7 | |
curr = {1: 1} | |
for ai in ais: | |
nxt = dd(int) | |
print "curr: %s" % (curr,) | |
print "ai: %s" % (ai,) | |
for key in curr: | |
for el in (1, ai): | |
nkey = key * gcd(k / key, el) | |
nxt[nkey] = (nxt[nkey] + el * curr[key]) % mod | |
curr = nxt | |
print curr[k] if k in curr else 0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment