結果

問題 No.372 It's automatic
ユーザー togari_takamototogari_takamoto
提出日時 2016-05-14 00:47:45
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2,808 ms / 6,000 ms
コード長 1,312 bytes
コンパイル時間 1,607 ms
コンパイル使用メモリ 163,080 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 18:35:57
合計ジャッジ時間 35,287 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,812 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2,647 ms
6,944 KB
testcase_05 AC 2,648 ms
6,944 KB
testcase_06 AC 2,658 ms
6,944 KB
testcase_07 AC 2,637 ms
6,940 KB
testcase_08 AC 2,662 ms
6,940 KB
testcase_09 AC 2,649 ms
6,940 KB
testcase_10 AC 2,808 ms
6,940 KB
testcase_11 AC 2,631 ms
6,940 KB
testcase_12 AC 2,665 ms
6,940 KB
testcase_13 AC 2,609 ms
5,376 KB
testcase_14 AC 2,660 ms
5,376 KB
testcase_15 AC 2,658 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 129 ms
5,376 KB
testcase_22 AC 132 ms
5,376 KB
testcase_23 AC 134 ms
5,376 KB
testcase_24 AC 135 ms
5,376 KB
testcase_25 AC 136 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
 
using ll = long long; using ld = long double; using ull = unsigned long long; using uint = unsigned int;
using vi  = vector<int>; using vb  = vector<bool>; using vd  = vector<double>; using vl  = vector<ll>;
using vvi = vector<vi>;  using vvb = vector<vb>;   using vvd = vector<vd>;     using vvl = vector<vl>;
 
#define REP(i,n) for(ll i=0; i<(n); ++i)
#define FOR(i,b,n) for(ll i=(b); i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define TEN(x) ((ll)1e##x)
 
template<typename T> inline string join(const vector<T>& vec, string sep = " ") { stringstream ss; REP(i, vec.size()) ss << vec[i] << ( i+1 == vec.size() ? "" : sep ); return ss.str(); }

int main() {
#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	string s; ll m; cin >> s >> m;

	int mod = TEN(9) + 7;
	vvi dp(2, vi(m, 0)); // dp[s.size()+1][m]
	REP(i, s.size()) {
		REP(j, m) dp[(i + 1) % 2][j] = 0;
		if (s[i] != '0') (dp[(i + 1)%2][(s[i] - '0') % m] += 1) %= mod;
		REP(j, m) {
			(dp[(i + 1)%2][(j * 10 + (s[i] - '0')) % m] += dp[i%2][j]) %= mod;
			(dp[(i + 1)%2][j] += dp[i%2][j]) %= mod;
		}
	}
	cout << dp[s.size()%2][0] + count(ALL(s), '0') << endl;
	return 0;
}
0