結果

問題 No.1086 桁和の桁和2
ユーザー KKT89KKT89
提出日時 2020-06-20 09:58:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 187 ms / 3,000 ms
コード長 1,189 bytes
コンパイル時間 932 ms
コンパイル使用メモリ 102,596 KB
実行使用メモリ 5,588 KB
最終ジャッジ日時 2023-09-30 00:00:52
合計ジャッジ時間 5,790 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 179 ms
5,588 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 110 ms
4,632 KB
testcase_11 AC 29 ms
4,380 KB
testcase_12 AC 6 ms
4,376 KB
testcase_13 AC 139 ms
4,800 KB
testcase_14 AC 88 ms
4,384 KB
testcase_15 AC 24 ms
4,380 KB
testcase_16 AC 128 ms
4,692 KB
testcase_17 AC 12 ms
4,380 KB
testcase_18 AC 180 ms
5,316 KB
testcase_19 AC 150 ms
4,844 KB
testcase_20 AC 19 ms
4,376 KB
testcase_21 AC 124 ms
4,692 KB
testcase_22 AC 179 ms
5,480 KB
testcase_23 AC 110 ms
4,428 KB
testcase_24 AC 80 ms
4,380 KB
testcase_25 AC 152 ms
4,804 KB
testcase_26 AC 122 ms
4,556 KB
testcase_27 AC 92 ms
4,380 KB
testcase_28 AC 75 ms
4,376 KB
testcase_29 AC 85 ms
4,380 KB
testcase_30 AC 179 ms
5,484 KB
testcase_31 AC 177 ms
5,464 KB
testcase_32 AC 181 ms
5,424 KB
testcase_33 AC 185 ms
5,484 KB
testcase_34 AC 187 ms
5,352 KB
testcase_35 AC 169 ms
5,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <math.h>
#include <deque>
#include <cstdio>
#include <queue>
#include <numeric>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

const ll mx=1e9;
constexpr ll mod=1e9+7;

ll mod_pow(ll a,ll b){
    a%=mod;
    if(b==0)return 1;
    if(b==1)return a;
    ll res=mod_pow(a,b/2)%mod;
    res*=res; res%=mod;
    if(b%2)res*=a;
    return res%mod;
}

ll cal(ll l,ll r,int p,int d){
    if(d==0){
        if(p==0){
            return 1LL;
        }
        else{
            return 0LL;
        }
    }
    else{
        ll tmp=(mod_pow(10,r)-mod_pow(10,l)+mod)%mod*mod_pow(9,mod-2);
        if(d==p)tmp++;
        return tmp%mod;
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> l(n),r(n),d(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 res=1;
    ll p=0;
    for(int i=0;i<n;i++){
        (res*=cal(l[i],r[i],p,d[i]))%=mod;
        p=d[i];
    }
    cout << res << endl;
}
0