結果

問題 No.1085 桁和の桁和
ユーザー potoooooooopotoooooooo
提出日時 2020-06-19 22:33:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 989 bytes
コンパイル時間 1,789 ms
コンパイル使用メモリ 201,336 KB
実行使用メモリ 814,552 KB
最終ジャッジ日時 2023-09-30 06:18:14
合計ジャッジ時間 3,212 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 MLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

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