結果

問題 No.372 It's automatic
ユーザー vwxyzvwxyz
提出日時 2023-02-16 07:08:58
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,053 ms / 6,000 ms
コード長 519 bytes
コンパイル時間 886 ms
コンパイル使用メモリ 99,760 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-25 13:00:40
合計ジャッジ時間 15,104 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1,043 ms
4,376 KB
testcase_05 AC 1,050 ms
4,376 KB
testcase_06 AC 1,038 ms
4,380 KB
testcase_07 AC 1,052 ms
4,380 KB
testcase_08 AC 1,053 ms
4,376 KB
testcase_09 AC 1,046 ms
4,376 KB
testcase_10 AC 1,048 ms
4,380 KB
testcase_11 AC 1,039 ms
4,376 KB
testcase_12 AC 1,050 ms
4,376 KB
testcase_13 AC 1,045 ms
4,380 KB
testcase_14 AC 1,049 ms
4,380 KB
testcase_15 AC 1,053 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 49 ms
4,380 KB
testcase_22 AC 48 ms
4,376 KB
testcase_23 AC 48 ms
4,380 KB
testcase_24 AC 49 ms
4,376 KB
testcase_25 AC 49 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
using namespace std;

long long dp[20000];
long long pre[20000];

int main(){
	string S;cin>>S;
	int M;cin>>M;
	long long mod=1000000007;
	long long ans=0;
	for(char s:S){
		int a=s-'0';
		for(int m=0;m<M;m++){
			pre[m]=dp[m];
		}
		for(int m=0;m<M;m++){
			dp[(10*m+a)%M]+=pre[m];
			dp[(10*m+a)%M]%=mod;
		}
		if(a){
			dp[a%M]+=1;
			dp[a%M]%=mod;
		}
		else{
			ans+=1;
		}
	}
	ans+=dp[0];
	ans%=mod;
	cout<<ans<<endl;
}
0