結果

問題 No.260 世界のなんとか3
ユーザー shobonvipshobonvip
提出日時 2022-08-07 19:36:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,253 bytes
コンパイル時間 111 ms
コンパイル使用メモリ 12,040 KB
実行使用メモリ 10,364 KB
最終ジャッジ日時 2023-10-17 14:14:38
合計ジャッジ時間 33,394 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,316 KB
testcase_01 AC 30 ms
10,316 KB
testcase_02 AC 30 ms
10,316 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 AC 455 ms
10,316 KB
testcase_06 AC 314 ms
10,316 KB
testcase_07 AC 1,570 ms
10,356 KB
testcase_08 AC 1,087 ms
10,336 KB
testcase_09 AC 613 ms
10,316 KB
testcase_10 AC 1,771 ms
10,364 KB
testcase_11 AC 1,668 ms
10,360 KB
testcase_12 AC 1,011 ms
10,332 KB
testcase_13 AC 305 ms
10,316 KB
testcase_14 AC 1,547 ms
10,356 KB
testcase_15 AC 417 ms
10,316 KB
testcase_16 AC 1,372 ms
10,352 KB
testcase_17 AC 1,035 ms
10,336 KB
testcase_18 AC 1,006 ms
10,332 KB
testcase_19 AC 1,301 ms
10,352 KB
testcase_20 AC 963 ms
10,324 KB
testcase_21 AC 821 ms
10,324 KB
testcase_22 AC 1,519 ms
10,356 KB
testcase_23 AC 162 ms
10,316 KB
testcase_24 AC 1,171 ms
10,348 KB
testcase_25 AC 1,188 ms
10,348 KB
testcase_26 AC 1,161 ms
10,348 KB
testcase_27 AC 28 ms
10,316 KB
testcase_28 TLE -
testcase_29 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10**9 + 7

def solve(x, mode):
	size = len(x)
	dpy = [0] * 24
	dpn = [0] * 24
	nowisy = 0
	now24 = 0
	for num in range(size):
		ndpy = [0] * 24
		ndpn = [0] * 24
		
		#継続
		for i in range(10):
			if i == 3:
				for j in range(24):
					ndpy[(i+10*j)%24] += dpy[j] + dpn[j]
					ndpy[(i+10*j)%24] %= mod
			else:
				for j in range(24):
					ndpy[(i+10*j)%24] += dpy[j]
					ndpy[(i+10*j)%24] %= mod
					ndpn[(i+10*j)%24] += dpn[j]
					ndpn[(i+10*j)%24] %= 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 % 24
		
		#解放
		if nowisy:
			for i in range(num<1, targ):
				ndpy[(i+now24)%24] += 1
		else:
			for i in range(num<1, targ):
				if i == 3:
					ndpy[(i+now24)%24] += 1
				else:
					ndpn[(i+now24)%24] += 1
		
		for i in range(24):
			dpn[i] = ndpn[i]
			dpy[i] = ndpy[i]
		
		if targ == 3:
			nowisy = 1
		
		now24 = (now24+targ) %24
	
	if mode:
		if nowisy:
			dpy[now24] += 1
		else:
			dpn[now24] += 1
	
	ans = 0
	for i in range(24):
		if i % 8 != 0:
			ans += dpy[i]
			ans %= mod
			if i % 3 == 0:
				ans += dpn[i]
				ans %= mod
	
	return ans
	

a,b = input().split()

print((solve(b, 1)-solve(a, 0)) % mod)
0