結果
問題 | No.372 It's automatic |
ユーザー |
![]() |
提出日時 | 2016-05-14 00:35:07 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,250 bytes |
コンパイル時間 | 2,359 ms |
コンパイル使用メモリ | 163,840 KB |
実行使用メモリ | 814,336 KB |
最終ジャッジ日時 | 2024-10-05 19:36:39 |
合計ジャッジ時間 | 2,930 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | WA * 1 MLE * 1 -- * 21 |
ソースコード
#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; ll mod = TEN(9) + 7; vvl dp(s.size()+1, vl(m, 0)); // dp[s.size()][m][空か否か] REP(i, s.size()) REP(j, m) { if (s[i] != '0') dp[i + 1][(s[i] - '0') % m] = 1; (dp[i+1][(j*10 + (s[i] - '0'))%m] += dp[i][j]) %= mod; (dp[i+1][j] += dp[i][j]) %= mod; } cout << dp[s.size()][0] + count(ALL(s), '0') << endl; return 0; }