結果
問題 | No.372 It's automatic |
ユーザー | Lay_ec |
提出日時 | 2016-05-15 01:32:24 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2,837 ms / 6,000 ms |
コード長 | 742 bytes |
コンパイル時間 | 813 ms |
コンパイル使用メモリ | 91,336 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-11 01:00:34 |
合計ジャッジ時間 | 37,433 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#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; }