結果
| 問題 | No.260 世界のなんとか3 |
| コンテスト | |
| ユーザー |
mkawa2
|
| 提出日時 | 2023-01-13 00:24:23 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,177 bytes |
| 記録 | |
| コンパイル時間 | 614 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-12-23 16:32:59 |
| 合計ジャッジ時間 | 40,163 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 TLE * 6 |
ソースコード
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)
mkawa2