結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 45 ms
5,716 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 27 ms
4,808 KB
testcase_11 AC 9 ms
4,376 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 36 ms
5,200 KB
testcase_14 AC 23 ms
4,536 KB
testcase_15 AC 16 ms
4,376 KB
testcase_16 AC 85 ms
4,968 KB
testcase_17 AC 8 ms
4,380 KB
testcase_18 WA -
testcase_19 AC 96 ms
5,196 KB
testcase_20 AC 13 ms
4,380 KB
testcase_21 AC 83 ms
4,948 KB
testcase_22 AC 116 ms
5,604 KB
testcase_23 AC 71 ms
4,740 KB
testcase_24 AC 48 ms
4,380 KB
testcase_25 AC 96 ms
5,516 KB
testcase_26 AC 81 ms
4,952 KB
testcase_27 AC 58 ms
4,576 KB
testcase_28 AC 49 ms
4,380 KB
testcase_29 WA -
testcase_30 AC 117 ms
5,748 KB
testcase_31 AC 117 ms
5,684 KB
testcase_32 WA -
testcase_33 AC 119 ms
5,680 KB
testcase_34 AC 117 ms
5,660 KB
testcase_35 AC 44 ms
5,728 KB
権限があれば一括ダウンロードができます

ソースコード

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;
    int cnt_plus = 0;
    for(int i = 0; i < N; i++){
        if(D[i] == 0){
            if(cnt_plus > 0){
                cout << 0 << endl;
                return 0;
            }
            ans = 1;
        }else{
            cnt_plus++;
            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]%9 == prev%9) tmp++;
            ans *= tmp;
            ans %= MOD;
        }
        prev = D[i];
    }
    cout << ans << endl;
}
0