結果

問題 No.1086 桁和の桁和2
ユーザー potoooooooopotoooooooo
提出日時 2020-06-19 22:36:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 120 ms / 3,000 ms
コード長 1,001 bytes
コンパイル時間 3,793 ms
コンパイル使用メモリ 200,676 KB
実行使用メモリ 5,548 KB
最終ジャッジ日時 2023-09-29 23:46:50
合計ジャッジ時間 5,821 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 45 ms
5,348 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 29 ms
4,644 KB
testcase_11 AC 9 ms
4,380 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 36 ms
4,784 KB
testcase_14 AC 23 ms
4,380 KB
testcase_15 AC 16 ms
4,376 KB
testcase_16 AC 84 ms
4,720 KB
testcase_17 AC 8 ms
4,380 KB
testcase_18 AC 116 ms
5,428 KB
testcase_19 AC 95 ms
4,836 KB
testcase_20 AC 13 ms
4,380 KB
testcase_21 AC 82 ms
4,516 KB
testcase_22 AC 115 ms
5,320 KB
testcase_23 AC 71 ms
4,380 KB
testcase_24 AC 49 ms
4,380 KB
testcase_25 AC 98 ms
4,840 KB
testcase_26 AC 80 ms
4,648 KB
testcase_27 AC 58 ms
4,380 KB
testcase_28 AC 48 ms
4,376 KB
testcase_29 AC 54 ms
4,376 KB
testcase_30 AC 119 ms
5,316 KB
testcase_31 AC 119 ms
5,500 KB
testcase_32 AC 119 ms
5,428 KB
testcase_33 AC 120 ms
5,548 KB
testcase_34 AC 119 ms
5,360 KB
testcase_35 AC 46 ms
5,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
constexpr int mod = 1000000007;

long long modpow(long long a, long long r) {
    long long ret = 1;
    while (r) {
        if (r & 1) ret = ret * a % mod;
        r >>= 1;
        a = a * a % mod;
    }
    return ret;
}
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<long long> L(N), R(N), D(N);
    for (auto &x: L) cin >> x;
    for (auto &x: R) cin >> x;
    for (auto &x: D) cin >> x;
    
    int Dc = 0;
    long long Ans = 1;
    long long inv9 = modpow(9, mod-2);

    for (int i = 0; i < N && Ans; i++) {
        if (D[i] == 0) {
            if (Dc != 0) Ans = 0;
            continue;
        }
        int Diff = (D[i] - Dc + 9) % 9;
        long long U = (modpow(10, R[i]) - modpow(10, L[i]) + mod) % mod * inv9 % mod;
        U = (U % mod + mod) % mod;
        if (Diff == 0 && Dc != 0) U++;
        Dc = D[i];
        Ans = Ans * U % mod;
    }
    cout << Ans << "\n";
    return 0;
}
0