結果

問題 No.1086 桁和の桁和2
ユーザー milanis48663220milanis48663220
提出日時 2020-06-19 23:19:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,216 bytes
コンパイル時間 672 ms
コンパイル使用メモリ 83,036 KB
実行使用メモリ 5,960 KB
最終ジャッジ日時 2023-09-16 15:32:53
合計ジャッジ時間 4,756 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 16 ms
4,376 KB
testcase_16 AC 84 ms
5,000 KB
testcase_17 AC 9 ms
4,380 KB
testcase_18 AC 116 ms
5,704 KB
testcase_19 AC 96 ms
5,256 KB
testcase_20 AC 13 ms
4,376 KB
testcase_21 AC 82 ms
4,960 KB
testcase_22 AC 115 ms
5,680 KB
testcase_23 AC 71 ms
4,884 KB
testcase_24 AC 50 ms
4,380 KB
testcase_25 AC 98 ms
5,280 KB
testcase_26 AC 80 ms
4,924 KB
testcase_27 AC 59 ms
4,488 KB
testcase_28 AC 49 ms
4,376 KB
testcase_29 AC 54 ms
4,472 KB
testcase_30 AC 119 ms
5,960 KB
testcase_31 AC 119 ms
5,776 KB
testcase_32 AC 119 ms
5,728 KB
testcase_33 AC 119 ms
5,700 KB
testcase_34 AC 119 ms
5,828 KB
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

template <typename T>
T pow(T a, ll n) {
	T ans = 1;
	T tmp = a;
	for (int i = 0; i <= 60; i++) {
		ll m = (ll)1 << i;
		if (m & n) {
		ans *= tmp;
		ans %= MOD;
		}
		tmp *= tmp;
		tmp %= MOD;
	}
	return ans;
}

ll inv(ll n){
    if(n == 1) return 1;
    else return MOD-inv(MOD%n)*(MOD/n)%MOD;
}


int N;
ll L[100000], R[100000], D[100000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++) cin >> L[i];
    for(int i = 0; i < N; i++) cin >> R[i];
    for(int i = 0; i < N; i++) cin >> D[i];
    ll ans = 1;
    int prev = 0;
    for(int i = 0; i < N; i++){
        if(D[i] == 0){
            cout << 0 << endl;
        }else{
            ll r = pow<ll>(10, R[i]);
            ll l = pow<ll>(10, L[i]);
            ll d = (r-l+MOD)%MOD;
            ll tmp = (d*inv(9))%MOD;
            if(D[i] == prev) tmp++;
            ans *= tmp;
            ans %= MOD;
        }
        prev = D[i];
    }
    cout << ans << endl;
}
0