結果

問題 No.372 It's automatic
ユーザー chocoruskchocorusk
提出日時 2019-07-20 01:53:58
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,524 ms / 6,000 ms
コード長 961 bytes
コンパイル時間 755 ms
コンパイル使用メモリ 96,832 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-27 04:05:05
合計ジャッジ時間 20,736 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1,510 ms
4,380 KB
testcase_05 AC 1,522 ms
4,380 KB
testcase_06 AC 1,512 ms
4,380 KB
testcase_07 AC 1,508 ms
4,376 KB
testcase_08 AC 1,518 ms
4,376 KB
testcase_09 AC 1,516 ms
4,384 KB
testcase_10 AC 1,521 ms
4,376 KB
testcase_11 AC 1,503 ms
4,376 KB
testcase_12 AC 1,524 ms
4,376 KB
testcase_13 AC 1,506 ms
4,376 KB
testcase_14 AC 1,517 ms
4,376 KB
testcase_15 AC 1,518 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 76 ms
4,376 KB
testcase_22 AC 78 ms
4,380 KB
testcase_23 AC 78 ms
4,376 KB
testcase_24 AC 77 ms
4,376 KB
testcase_25 AC 77 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
    string s;
    int m;
    cin>>s>>m;
    int n=s.size();
    ll dp[2][20002]={};
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            dp[(i&1)^1][j]=dp[i&1][j];
        }
        int x=s[i]-'0';
        if(x!=0) (dp[(i&1)^1][x%m]+=1)%=MOD;
        for(int j=0; j<m; j++){
            (dp[(i&1)^1][(10*j+x)%m]+=dp[i&1][j])%=MOD;
        }
    }
    ll ans=dp[n&1][0];
    for(int i=0; i<n; i++) if(s[i]=='0') (ans+=1)%=MOD;
    cout<<ans<<endl;
    return 0;
}
0