結果
| 問題 | No.1086 桁和の桁和2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-20 09:58:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 204 ms / 3,000 ms |
| コード長 | 1,189 bytes |
| 記録 | |
| コンパイル時間 | 1,065 ms |
| コンパイル使用メモリ | 100,068 KB |
| 最終ジャッジ日時 | 2025-01-11 08:33:01 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 31 |
ソースコード
#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;
}