結果

問題 No.372 It's automatic
ユーザー kimiyukikimiyuki
提出日時 2016-05-24 21:55:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 875 bytes
コンパイル時間 799 ms
コンパイル使用メモリ 71,920 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-16 12:24:02
合計ジャッジ時間 21,962 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1,652 ms
5,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1,657 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1,659 ms
5,376 KB
testcase_15 WA -
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 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 86 ms
5,376 KB
testcase_25 AC 86 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
typedef long long ll;
using namespace std;
const int mod = 1e9+7;
int main() {
    string s; int m; cin >> s >> m;
    vector<int> cur(m);
    vector<int> prv;
    int ans = 0;
    for (char c : s) {
        int d = c - '0';
        cur.swap(prv);
        cur.clear();
        cur.resize(m);
        repeat (i,m) {
            cur[i] += prv[i];
            cur[(i * 10 + d) % m] += prv[i];
            if ((i * 10 + d) % m == 0) {
                ans += prv[i];
            }
        }
        if (d == 0) {
            ans += 1;
        } else {
            cur[d % m] += 1;
            if (d % m == 0) {
                ans += 1;
            }
        }
        repeat (i,m) {
            cur[i] %= mod;
        }
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}
0