結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,160 KB
testcase_01 AC 32 ms
10,160 KB
testcase_02 AC 32 ms
10,160 KB
testcase_03 TLE -
testcase_04 TLE -
testcase_05 AC 473 ms
10,160 KB
testcase_06 AC 324 ms
10,160 KB
testcase_07 AC 1,624 ms
10,200 KB
testcase_08 AC 1,135 ms
10,180 KB
testcase_09 AC 636 ms
10,160 KB
testcase_10 AC 1,831 ms
10,208 KB
testcase_11 AC 1,748 ms
10,204 KB
testcase_12 AC 1,040 ms
10,176 KB
testcase_13 AC 313 ms
10,160 KB
testcase_14 AC 1,559 ms
10,200 KB
testcase_15 AC 427 ms
10,160 KB
testcase_16 AC 1,368 ms
10,196 KB
testcase_17 AC 1,083 ms
10,180 KB
testcase_18 AC 1,037 ms
10,176 KB
testcase_19 AC 1,358 ms
10,196 KB
testcase_20 AC 957 ms
10,168 KB
testcase_21 AC 854 ms
10,168 KB
testcase_22 AC 1,558 ms
10,200 KB
testcase_23 AC 169 ms
10,160 KB
testcase_24 AC 1,207 ms
10,192 KB
testcase_25 AC 1,219 ms
10,192 KB
testcase_26 AC 1,210 ms
10,192 KB
testcase_27 AC 29 ms
10,160 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