結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー 👑 potato167potato167
提出日時 2022-02-17 01:09:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 135 ms / 3,000 ms
コード長 732 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 78,872 KB
最終ジャッジ日時 2023-09-11 17:20:29
合計ジャッジ時間 5,202 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,224 KB
testcase_01 AC 73 ms
71,280 KB
testcase_02 AC 85 ms
76,472 KB
testcase_03 AC 71 ms
71,272 KB
testcase_04 AC 72 ms
71,056 KB
testcase_05 AC 72 ms
70,888 KB
testcase_06 AC 71 ms
71,008 KB
testcase_07 AC 73 ms
71,344 KB
testcase_08 AC 73 ms
71,348 KB
testcase_09 AC 71 ms
70,884 KB
testcase_10 AC 73 ms
71,112 KB
testcase_11 AC 72 ms
71,052 KB
testcase_12 AC 77 ms
75,960 KB
testcase_13 AC 78 ms
75,868 KB
testcase_14 AC 81 ms
75,876 KB
testcase_15 AC 82 ms
75,900 KB
testcase_16 AC 84 ms
75,912 KB
testcase_17 AC 83 ms
76,432 KB
testcase_18 AC 85 ms
76,532 KB
testcase_19 AC 85 ms
76,260 KB
testcase_20 AC 82 ms
76,528 KB
testcase_21 AC 85 ms
76,356 KB
testcase_22 AC 85 ms
76,372 KB
testcase_23 AC 83 ms
76,380 KB
testcase_24 AC 84 ms
76,480 KB
testcase_25 AC 85 ms
76,080 KB
testcase_26 AC 85 ms
76,252 KB
testcase_27 AC 86 ms
76,472 KB
testcase_28 AC 85 ms
76,264 KB
testcase_29 AC 90 ms
76,456 KB
testcase_30 AC 99 ms
77,232 KB
testcase_31 AC 93 ms
76,508 KB
testcase_32 AC 120 ms
77,568 KB
testcase_33 AC 114 ms
77,992 KB
testcase_34 AC 132 ms
78,700 KB
testcase_35 AC 128 ms
78,756 KB
testcase_36 AC 135 ms
78,796 KB
testcase_37 AC 120 ms
78,872 KB
testcase_38 AC 114 ms
78,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S=input()
N=len(S)
dp=[[0 for i in range(9)] for j in range(N+1)]
MOD=10**9+7
q=[0,0,1,0,2,3,1,0,2,0]
A=0
B=0
J=0
for i in range(N):
	for k in range(ord(S[i])-ord('0')):
		a=A
		b=B
		if q[k]==3:
			if b!=2:
				b+=1
		else:
			a+=q[k]
			if a>2:
				a=2
		if k!=0 and J==0:
			dp[i+1][a+b*3]+=1
	if S[i]=='5':
		B=min(2,B+1)
	elif S[i]=='0':
		J=1
	else:
		A=min(A+q[ord(S[i])-ord('0')],2)
	if i==0:
		continue
	for j in range(9):
		dp[i][j]%=MOD
		if dp[i][j]==0:
			continue
		for k in range(1,10):
			a=j%3
			b=j//3
			if q[k]==3 and b!=2:
				b+=1
			elif q[k]!=3:
				a+=q[k]
				if a>2:
					a=2
			dp[i+1][a+b*3]+=dp[i][j]
	for j in range(9):
		dp[i+1][q[j+1]]+=1
if A==2 and B==2 and J==0:
	dp[N][8]+=1
print(dp[N][8]%MOD)
0