結果

問題 No.372 It's automatic
ユーザー Y17Y17
提出日時 2020-02-05 01:15:19
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2,392 ms / 6,000 ms
コード長 687 bytes
コンパイル時間 1,426 ms
コンパイル使用メモリ 160,548 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 06:44:43
合計ジャッジ時間 32,043 ms
ジャッジサーバーID
(参考情報)
judge14 / judge9
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2,356 ms
4,348 KB
testcase_05 AC 2,364 ms
4,348 KB
testcase_06 AC 2,362 ms
4,348 KB
testcase_07 AC 2,386 ms
4,348 KB
testcase_08 AC 2,392 ms
4,348 KB
testcase_09 AC 2,375 ms
4,348 KB
testcase_10 AC 2,373 ms
4,348 KB
testcase_11 AC 2,355 ms
4,348 KB
testcase_12 AC 2,377 ms
4,348 KB
testcase_13 AC 2,360 ms
4,348 KB
testcase_14 AC 2,381 ms
4,348 KB
testcase_15 AC 2,384 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 3 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 199 ms
4,348 KB
testcase_22 AC 200 ms
4,348 KB
testcase_23 AC 198 ms
4,348 KB
testcase_24 AC 200 ms
4,348 KB
testcase_25 AC 198 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define MOD 1000000007

signed main(){
    string s;
    int m;
    cin >> s >> m;
    int n = s.size();

    int dp[20000] = {};

    int ans = 0;
    for(int i = 0;i < n;i++){
        int dp2[20000];
        memcpy(dp2, dp, sizeof(dp));
        for(int j = 0;j < m;j++){
            dp2[(j*10+(s[i]-'0'))%m] += dp[j]; 
            dp2[(j*10+(s[i]-'0'))%m] %= MOD; 
        }
        if(s[i] != '0'){
            dp2[(s[i]-'0')%m]++; 
            dp2[(s[i]-'0')%m]%=MOD; 
        }else{
            ans++;
        }

        memcpy(dp, dp2, sizeof(dp));
    }

    cout << (dp[0] + ans)%MOD << endl;
    return 0;
}

0