結果

問題 No.1086 桁和の桁和2
ユーザー potoooooooopotoooooooo
提出日時 2020-06-19 22:34:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 989 bytes
コンパイル時間 1,932 ms
コンパイル使用メモリ 201,688 KB
実行使用メモリ 5,644 KB
最終ジャッジ日時 2023-09-16 14:49:50
合計ジャッジ時間 5,608 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 45 ms
5,540 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 29 ms
4,524 KB
testcase_11 AC 9 ms
4,376 KB
testcase_12 AC 3 ms
4,376 KB
testcase_13 AC 36 ms
4,924 KB
testcase_14 AC 24 ms
4,380 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 46 ms
5,400 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(mod-2, 9);

    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])) * 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