結果

問題 No.372 It's automatic
ユーザー mamekinmamekin
提出日時 2016-05-22 23:52:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 963 ms / 6,000 ms
コード長 997 bytes
コンパイル時間 808 ms
コンパイル使用メモリ 105,704 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-19 12:47:24
合計ジャッジ時間 13,286 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 920 ms
5,376 KB
testcase_05 AC 918 ms
5,376 KB
testcase_06 AC 924 ms
5,376 KB
testcase_07 AC 949 ms
5,376 KB
testcase_08 AC 939 ms
5,376 KB
testcase_09 AC 945 ms
5,376 KB
testcase_10 AC 941 ms
5,376 KB
testcase_11 AC 933 ms
5,376 KB
testcase_12 AC 937 ms
5,376 KB
testcase_13 AC 940 ms
5,376 KB
testcase_14 AC 963 ms
5,376 KB
testcase_15 AC 949 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 49 ms
5,376 KB
testcase_22 AC 48 ms
5,376 KB
testcase_23 AC 49 ms
5,376 KB
testcase_24 AC 50 ms
5,376 KB
testcase_25 AC 51 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

const int MOD = 1000000007;

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

    vector<int> dp(m, 0);
    for(int i=0; i<n; ++i){
        vector<int> nextDp = dp;
        if(s[i] != '0')
            ++ nextDp[(s[i] - '0') % m];

        for(int a=0; a<m; ++a){
            int b = (a * 10 + s[i] - '0') % m;
            nextDp[b] += dp[a];
            nextDp[b] %= MOD;
        }

        dp.swap(nextDp);
    }

    int ans = dp[0];
    ans += count(s.begin(), s.end(), '0');
    ans %= MOD;
    cout << ans << endl;

    return 0;
}
0