結果

問題 No.372 It's automatic
ユーザー pekempeypekempey
提出日時 2016-10-29 06:50:06
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 468 ms / 6,000 ms
コード長 716 bytes
コンパイル時間 1,896 ms
コンパイル使用メモリ 169,864 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-03 08:44:48
合計ジャッジ時間 8,772 ms
ジャッジサーバーID
(参考情報)
judge3 / 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 462 ms
5,376 KB
testcase_05 AC 465 ms
5,376 KB
testcase_06 AC 463 ms
5,376 KB
testcase_07 AC 465 ms
5,376 KB
testcase_08 AC 467 ms
5,376 KB
testcase_09 AC 465 ms
5,376 KB
testcase_10 AC 466 ms
5,376 KB
testcase_11 AC 460 ms
5,376 KB
testcase_12 AC 465 ms
5,376 KB
testcase_13 AC 462 ms
5,376 KB
testcase_14 AC 468 ms
5,376 KB
testcase_15 AC 466 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 46 ms
5,376 KB
testcase_23 AC 45 ms
5,376 KB
testcase_24 AC 49 ms
5,376 KB
testcase_25 AC 49 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |     scanf("%s %d", S, &M);
      |     ~~~~~^~~~~~~~~~~~~~~~

ソースコード

diff #

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

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

const int mod = 1e9 + 7;

char S[10001];
int M, dp0[20000], dp1[20000];

void upd(int &x, int y) {
    x += y;
    if (x >= mod) x -= mod;
}

int main() {
    scanf("%s %d", S, &M);
    int n = strlen(S), d = 10 % M;
    for (int i = 0; i < n; i++) S[i] -= '0';
    for (int i = 0; i < n; i++) {
        memcpy(dp1, dp0, sizeof(dp1));
        if (S[i] != 0) dp0[S[i] % M]++;
        short k = S[i] % M;
        for (int j = 0; j < M; j++) {
            upd(dp0[k], dp1[j]);
            k += d;
            if (k >= M) k -= M;
        }
    }
    dp0[0] += count(S, S + n, 0);
    cout << dp0[0] % mod << endl;
}

0