結果

問題 No.372 It's automatic
ユーザー Lay_ecLay_ec
提出日時 2016-05-15 01:32:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,818 ms / 6,000 ms
コード長 742 bytes
コンパイル時間 740 ms
コンパイル使用メモリ 83,672 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-01 08:57:07
合計ジャッジ時間 37,133 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2,782 ms
4,384 KB
testcase_05 AC 2,806 ms
4,380 KB
testcase_06 AC 2,794 ms
4,380 KB
testcase_07 AC 2,792 ms
4,380 KB
testcase_08 AC 2,813 ms
4,380 KB
testcase_09 AC 2,792 ms
4,380 KB
testcase_10 AC 2,793 ms
4,380 KB
testcase_11 AC 2,773 ms
4,380 KB
testcase_12 AC 2,818 ms
4,380 KB
testcase_13 AC 2,775 ms
4,380 KB
testcase_14 AC 2,808 ms
4,380 KB
testcase_15 AC 2,815 ms
4,384 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 328 ms
4,384 KB
testcase_22 AC 326 ms
4,380 KB
testcase_23 AC 325 ms
4,380 KB
testcase_24 AC 331 ms
4,384 KB
testcase_25 AC 327 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>

using namespace std;

const long long mod=1000000007; 



int main()
{
	string s;
	long long m;
	cin>>s>>m;
	
	long long res=0;
	long long dp[20001]={};
	for(int i=0;i<s.size();i++){
		long long dp2[20001]={};
		for(int j=0;j<m;j++){
			dp2[ (j*10+(s[i]-'0'))%m ] += dp[j];
			dp2[ (j*10+(s[i]-'0'))%m ] %= mod;
			
			dp2[j]+=dp[j];
			dp2[j]%=mod;
		}
		
		if(s[i]=='0') res++;
		else dp2[(s[i]-'0')%m]++;
		
		swap(dp,dp2);
	}
	
	res+=dp[0];
	res%=mod;
	cout<<res<<endl;

	return 0;
}
0