結果
問題 | No.372 It's automatic |
ユーザー |
![]() |
提出日時 | 2016-05-13 23:08:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 479 ms / 6,000 ms |
コード長 | 713 bytes |
コンパイル時間 | 1,774 ms |
コンパイル使用メモリ | 169,564 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-11 00:37:55 |
合計ジャッジ時間 | 8,018 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <bits/stdc++.h> using namespace std; struct INIT{INIT(){ios::sync_with_stdio(false);cin.tie(0);}}init; const int mod=1e9+7; int main() { string S; int M; cin >> S >> M; int n = S.size(); vector<int> dp(M,0); int ten=10%M; int res=0; for(int i = 0; i < n; i++){ auto nxt=dp; int np=(S[i]-'0'); if(np!=0)nxt[np%M]++; else res++; np%=M; for(int j = 0; j < M; j++){ nxt[np]+=dp[j]; if(nxt[np]>=mod)nxt[np]-=mod; np+=ten; if(np>=M)np-=M; //cout << np << " " << nxt[np] << endl; } swap(dp,nxt); } cout << (res+dp[0])%mod << endl; return 0; }