結果

問題 No.1086 桁和の桁和2
ユーザー albatross_35albatross_35
提出日時 2020-06-26 00:27:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 4,392 bytes
コンパイル時間 1,869 ms
コンパイル使用メモリ 203,256 KB
実行使用メモリ 5,568 KB
最終ジャッジ日時 2023-09-16 23:23:25
合計ジャッジ時間 9,355 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 43 ms
5,472 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 27 ms
4,676 KB
testcase_11 AC 8 ms
4,376 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 33 ms
4,868 KB
testcase_14 AC 21 ms
4,376 KB
testcase_15 AC 49 ms
4,376 KB
testcase_16 AC 268 ms
4,620 KB
testcase_17 AC 24 ms
4,380 KB
testcase_18 AC 387 ms
5,568 KB
testcase_19 AC 310 ms
4,952 KB
testcase_20 AC 41 ms
4,380 KB
testcase_21 AC 269 ms
4,688 KB
testcase_22 AC 379 ms
5,408 KB
testcase_23 AC 231 ms
4,384 KB
testcase_24 AC 162 ms
4,376 KB
testcase_25 AC 312 ms
4,916 KB
testcase_26 AC 259 ms
4,652 KB
testcase_27 AC 185 ms
4,380 KB
testcase_28 AC 155 ms
4,376 KB
testcase_29 AC 170 ms
4,376 KB
testcase_30 AC 381 ms
5,352 KB
testcase_31 AC 378 ms
5,472 KB
testcase_32 AC 381 ms
5,472 KB
testcase_33 AC 376 ms
5,464 KB
testcase_34 AC 382 ms
5,424 KB
testcase_35 AC 42 ms
5,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

const int MOD = 1000000007;
using mint = Fp<MOD>;

ll pow(ll x,ll y,ll mod){
    if(y==0) return 1;
    if(y&1) return x*pow(x,y-1,mod)%mod;
    ll p=pow(x,y/2,mod);
    return p*p%mod;
}


void solve(){
    ll n;
    cin >> n;
    mint ans=1;
    bool zero=true;
    Vi l(n),r(n),d(n);
    rp(i,n) cin >> l[i];
    rp(i,n) cin >> r[i];
    rp(i,n) cin >> d[i];
    rp(i,n){
        if(!zero&&d[i]==0){
            print(0);
            return;
        }
        if(zero&&d[i]==0){
            continue;
        }
        zero=false;
        mint res;
        if(l[i]==0){
            res=(pow(10,r[i],Mod)-1)/9;
        }else{
            res=(mint)(pow(10,r[i]-1,Mod)-pow(10,l[i]-1,Mod))/(mint)9;
            res*=10;
            if(i>0&&d[i]==d[i-1]) res+=1;
        }
        ans*=res;
    }
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}
0