結果

問題 No.1086 桁和の桁和2
ユーザー chocoruskchocorusk
提出日時 2020-06-19 22:42:14
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 215 ms / 3,000 ms
コード長 1,620 bytes
コンパイル時間 2,729 ms
コンパイル使用メモリ 127,344 KB
実行使用メモリ 5,412 KB
最終ジャッジ日時 2023-09-29 23:49:36
合計ジャッジ時間 6,868 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 140 ms
5,292 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 87 ms
4,556 KB
testcase_11 AC 25 ms
4,376 KB
testcase_12 AC 6 ms
4,376 KB
testcase_13 AC 112 ms
4,808 KB
testcase_14 AC 71 ms
4,380 KB
testcase_15 AC 27 ms
4,380 KB
testcase_16 AC 150 ms
4,656 KB
testcase_17 AC 14 ms
4,376 KB
testcase_18 AC 208 ms
5,184 KB
testcase_19 AC 170 ms
4,952 KB
testcase_20 AC 22 ms
4,380 KB
testcase_21 AC 147 ms
4,696 KB
testcase_22 AC 211 ms
5,316 KB
testcase_23 AC 127 ms
4,724 KB
testcase_24 AC 89 ms
4,376 KB
testcase_25 AC 175 ms
4,948 KB
testcase_26 AC 144 ms
4,668 KB
testcase_27 AC 104 ms
4,380 KB
testcase_28 AC 87 ms
4,376 KB
testcase_29 AC 96 ms
4,380 KB
testcase_30 AC 214 ms
5,296 KB
testcase_31 AC 214 ms
5,412 KB
testcase_32 AC 215 ms
5,292 KB
testcase_33 AC 214 ms
5,224 KB
testcase_34 AC 213 ms
5,276 KB
testcase_35 AC 140 ms
5,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
int main()
{
    int n; cin>>n;
    ll l[100010], r[100010];
    int d[100010];
    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];
    int z=-1;
    for(int i=n-1; i>=0; i--){
        if(d[i]==0){
            z=i; break;
        }
    }
    for(int i=0; i<z; i++){
        if(d[i]!=0){
            cout<<0<<endl;
            return 0;
        }
    }
    if(z==n-1){
        cout<<1<<endl;
        return 0;
    }
    for(int i=n-1; i>=z+1; i--){
        d[i]%=9;
        if(i) d[i]=(d[i]+9-d[i-1])%9;
    }
    ll ans=1;
    ll myon=inv(9);
    for(int i=z+1; i<n; i++){
        ll c=(powmod(10, r[i])-powmod(10, l[i])+MOD)*myon%MOD;
        if(i>z+1 && d[i]==0) c++;
        (ans*=c)%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}
0