結果
問題 |
No.372 It's automatic
|
ユーザー |
![]() |
提出日時 | 2023-02-16 07:08:58 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 931 ms / 6,000 ms |
コード長 | 519 bytes |
コンパイル時間 | 832 ms |
コンパイル使用メモリ | 99,244 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-18 10:19:00 |
合計ジャッジ時間 | 12,935 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#include <string> #include <iostream> #include <vector> #include <algorithm> #include <deque> using namespace std; long long dp[20000]; long long pre[20000]; int main(){ string S;cin>>S; int M;cin>>M; long long mod=1000000007; long long ans=0; for(char s:S){ int a=s-'0'; for(int m=0;m<M;m++){ pre[m]=dp[m]; } for(int m=0;m<M;m++){ dp[(10*m+a)%M]+=pre[m]; dp[(10*m+a)%M]%=mod; } if(a){ dp[a%M]+=1; dp[a%M]%=mod; } else{ ans+=1; } } ans+=dp[0]; ans%=mod; cout<<ans<<endl; }