結果

問題 No.260 世界のなんとか3
ユーザー shobonvipshobonvip
提出日時 2022-08-07 19:35:40
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,253 bytes
コンパイル時間 1,511 ms
コンパイル使用メモリ 81,248 KB
実行使用メモリ 75,488 KB
最終ジャッジ日時 2023-10-17 14:13:29
合計ジャッジ時間 4,514 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,296 KB
testcase_01 AC 41 ms
59,244 KB
testcase_02 AC 42 ms
59,244 KB
testcase_03 MLE -
testcase_04 MLE -
testcase_05 MLE -
testcase_06 MLE -
testcase_07 MLE -
testcase_08 MLE -
testcase_09 MLE -
testcase_10 MLE -
testcase_11 MLE -
testcase_12 MLE -
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 MLE -
testcase_17 MLE -
testcase_18 MLE -
testcase_19 MLE -
testcase_20 MLE -
testcase_21 MLE -
testcase_22 MLE -
testcase_23 MLE -
testcase_24 MLE -
testcase_25 MLE -
testcase_26 MLE -
testcase_27 AC 37 ms
53,348 KB
testcase_28 MLE -
testcase_29 MLE -
権限があれば一括ダウンロードができます

ソースコード

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