結果
問題 |
No.260 世界のなんとか3
|
ユーザー |
![]() |
提出日時 | 2023-01-13 00:20:49 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,177 bytes |
コンパイル時間 | 790 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 76,928 KB |
最終ジャッジ日時 | 2024-12-23 16:29:58 |
合計ジャッジ時間 | 6,646 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 1 MLE * 26 |
ソースコード
import sys def SI(): return sys.stdin.readline().rstrip() md = 10**9+7 def dodp(aa, eq): dp = [[0]*24, [0]*24] s = t = 0 for i, a in enumerate(aa): ndp = [[0]*24, [0]*24] for f in range(2): for j in range(24): pre = dp[f][j] if pre == 0: continue for d in range(10): nf = f | (d == 3) nj = (j*10+d)%24 ndp[nf][nj] += pre ndp[nf][nj] %= md for d in range(i == 0, a): nf = t | (d == 3) nj = (s*10+d)%24 ndp[nf][nj] += 1 if i: for d in range(1, 10): ndp[d == 3][d] += 1 if a == 3: t = 1 s = (s*10+a)%24 dp = ndp res = 0 for j in range(3, 24, 3): res += dp[0][j] res %= md for j in range(24): if j%8 == 0: continue res += dp[1][j] res %= md if eq and s%8 and (t or s%3 == 0): res += 1 return res aa=[[],[]] i=0 for c in SI(): if c==" ": i+=1 else: aa[i].append(int(c)) ans = dodp(aa[1], 1)-dodp(aa[0], 0) print(ans%md)