結果

問題 No.1417 100の倍数かつ正整数(2)
ユーザー 沙耶花沙耶花
提出日時 2021-03-05 21:36:17
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 312 ms / 3,000 ms
コード長 1,114 bytes
コンパイル時間 5,020 ms
コンパイル使用メモリ 263,944 KB
実行使用メモリ 130,944 KB
最終ジャッジ日時 2024-04-16 09:00:40
合計ジャッジ時間 13,959 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 186 ms
129,040 KB
testcase_01 AC 187 ms
129,024 KB
testcase_02 AC 188 ms
129,152 KB
testcase_03 AC 188 ms
129,024 KB
testcase_04 AC 188 ms
129,036 KB
testcase_05 AC 188 ms
129,040 KB
testcase_06 AC 186 ms
129,044 KB
testcase_07 AC 186 ms
129,024 KB
testcase_08 AC 191 ms
129,040 KB
testcase_09 AC 188 ms
129,024 KB
testcase_10 AC 187 ms
129,024 KB
testcase_11 AC 187 ms
129,040 KB
testcase_12 AC 187 ms
129,024 KB
testcase_13 AC 188 ms
129,164 KB
testcase_14 AC 188 ms
129,024 KB
testcase_15 AC 187 ms
129,152 KB
testcase_16 AC 186 ms
129,152 KB
testcase_17 AC 187 ms
129,152 KB
testcase_18 AC 192 ms
129,024 KB
testcase_19 AC 189 ms
129,176 KB
testcase_20 AC 187 ms
129,024 KB
testcase_21 AC 188 ms
129,024 KB
testcase_22 AC 189 ms
129,152 KB
testcase_23 AC 188 ms
129,152 KB
testcase_24 AC 187 ms
129,024 KB
testcase_25 AC 188 ms
129,024 KB
testcase_26 AC 188 ms
129,152 KB
testcase_27 AC 189 ms
129,152 KB
testcase_28 AC 189 ms
129,028 KB
testcase_29 AC 189 ms
129,024 KB
testcase_30 AC 197 ms
129,152 KB
testcase_31 AC 189 ms
129,024 KB
testcase_32 AC 213 ms
129,536 KB
testcase_33 AC 250 ms
129,920 KB
testcase_34 AC 308 ms
130,944 KB
testcase_35 AC 312 ms
130,944 KB
testcase_36 AC 312 ms
130,816 KB
testcase_37 AC 312 ms
130,816 KB
testcase_38 AC 205 ms
129,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint1000000007;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001
string s;

mint get(int pos,int m,int f){
	static vector dp(10005,vector(100,vector<mint>(2,0)));
	static vector visited(10005,vector(100,vector<bool>(2,false)));

	if(visited[pos][m][f])return dp[pos][m][f];
	if(pos==s.size()){
		if(m==0)return 1;
		else return 0;
	}

	visited[pos][m][f] = true;

	mint ret = 0;
	int t = s[pos]-'0';

	for(int i=1;i<=9;i++){
		if(i<t){
			ret += get(pos+1,m*i%100,1);
		}
		else if(i==t){
			ret += get(pos+1,m*i%100,f);
		}
		else{
			if(f)ret += get(pos+1,m*i%100,f);
		}
	}
	dp[pos][m][f] = ret;
	return ret;
}

int main(){
	
	cin>>s;
	mint ans = 0;
	{
		vector<mint> dp(100,0);
		dp[1] = 1;
		rep(i,s.size()-1){
			vector<mint> ndp(100,0);
			rep(j,100){
				rep(k,10){
					if(k==0)continue;
					ndp[j*k%100] += dp[j];
				}
			}
			swap(dp,ndp);
			ans += dp[0];
		}
	}
	//cout<<ans.val()<<endl;
	ans += get(0,1,0);
	cout<<ans.val()<<endl;
	
    return 0;
}
0