結果
問題 | No.315 世界のなんとか3.5 |
ユーザー | shobonvip |
提出日時 | 2022-08-07 19:49:26 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,276 bytes |
コンパイル時間 | 286 ms |
コンパイル使用メモリ | 81,804 KB |
実行使用メモリ | 80,504 KB |
最終ジャッジ日時 | 2023-10-17 14:31:24 |
合計ジャッジ時間 | 8,998 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
53,528 KB |
testcase_01 | AC | 49 ms
61,780 KB |
testcase_02 | AC | 57 ms
63,924 KB |
testcase_03 | AC | 44 ms
59,560 KB |
testcase_04 | AC | 46 ms
59,560 KB |
testcase_05 | AC | 48 ms
61,780 KB |
testcase_06 | AC | 57 ms
63,924 KB |
testcase_07 | AC | 51 ms
61,780 KB |
testcase_08 | AC | 49 ms
61,780 KB |
testcase_09 | AC | 45 ms
59,560 KB |
testcase_10 | AC | 45 ms
59,560 KB |
testcase_11 | AC | 45 ms
59,560 KB |
testcase_12 | AC | 689 ms
75,868 KB |
testcase_13 | AC | 697 ms
75,780 KB |
testcase_14 | AC | 1,301 ms
76,588 KB |
testcase_15 | AC | 1,302 ms
76,588 KB |
testcase_16 | TLE | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
ソースコード
mod = 10**9 + 7 a,b,ps = input().split() p = int(ps) def solve(x, mode): size = len(x) tp = 3*p dpy = [0] * tp dpn = [0] * tp nowisy = 0 now24 = 0 for num in range(size): ndpy = [0] * tp ndpn = [0] * tp #継続 for i in range(10): if i == 3: for j in range(tp): ndpy[(i+10*j)%tp] += dpy[j] + dpn[j] ndpy[(i+10*j)%tp] %= mod else: for j in range(tp): ndpy[(i+10*j)%tp] += dpy[j] ndpy[(i+10*j)%tp] %= mod ndpn[(i+10*j)%tp] += dpn[j] ndpn[(i+10*j)%tp] %= mod #新規 if num > 0: for i in range(1, 10): if i == 3: ndpy[i] += 1 else: ndpn[i] += 1 targ = int(x[num]) now24 = now24 * 10 % tp #解放 if nowisy: for i in range(num<1, targ): ndpy[(i+now24)%tp] += 1 else: for i in range(num<1, targ): if i == 3: ndpy[(i+now24)%tp] += 1 else: ndpn[(i+now24)%tp] += 1 for i in range(tp): dpn[i] = ndpn[i] dpy[i] = ndpy[i] if targ == 3: nowisy = 1 now24 = (now24+targ) % tp if mode: if nowisy: dpy[now24] += 1 else: dpn[now24] += 1 ans = 0 for i in range(tp): if i % p != 0: ans += dpy[i] ans %= mod if i % 3 == 0: ans += dpn[i] ans %= mod return ans print((solve(b, 1)-solve(a, 0)) % mod)