結果
| 問題 |
No.1086 桁和の桁和2
|
| コンテスト | |
| ユーザー |
kmjp
|
| 提出日時 | 2020-06-19 22:47:53 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 167 ms / 3,000 ms |
| コード長 | 1,290 bytes |
| コンパイル時間 | 1,947 ms |
| コンパイル使用メモリ | 196,176 KB |
| 最終ジャッジ日時 | 2025-01-11 07:27:42 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
int N;
ll L[101010],R[101010];
ll D;
const ll mo=1000000007;
ll dp[101010][10];
ll modpow(ll a, ll n = mo-2) {
ll r=1;a%=mo;
while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
return r;
}
void solve() {
int i,j,k,l,r,x,y; string s;
cin>>N;
FOR(i,N) cin>>L[i];
FOR(i,N) cin>>R[i];
dp[0][0]=1;
FOR(i,N) {
cin>>D;
ll num=(modpow(10,R[i])-modpow(10,L[i])+mo)*modpow(9)%mo;
FOR(x,10) {
FOR(y,10) {
int z=x+y;
if(z>9) z-=9;
if(z!=D) continue;
if(y==0) (dp[i+1][z]+=dp[i][x])%=mo;
else (dp[i+1][z]+=num*dp[i][x])%=mo;
}
}
}
ll ret=0;
FOR(i,10) ret+=dp[N][i];
cout<<ret<<endl;
}
int main(int argc,char** argv){
string s;int i;
if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
cout.tie(0); solve(); return 0;
}
kmjp