結果

問題 No.1086 桁和の桁和2
ユーザー Y17Y17
提出日時 2020-06-19 22:54:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,076 bytes
コンパイル時間 2,195 ms
コンパイル使用メモリ 166,076 KB
実行使用メモリ 6,644 KB
最終ジャッジ日時 2023-09-16 15:06:52
合計ジャッジ時間 7,501 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 3 ms
4,376 KB
testcase_04 WA -
testcase_05 AC 231 ms
6,504 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 143 ms
5,504 KB
testcase_11 AC 39 ms
4,560 KB
testcase_12 AC 9 ms
4,380 KB
testcase_13 AC 182 ms
5,888 KB
testcase_14 AC 114 ms
5,276 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 232 ms
6,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define MOD 1000000007 

int n;
int l[100010];
int r[100010]; 
int d[100010];

int pow_mod(int n, int m){
	int ans = 1;
	while(m > 0){
		if(m & 1) ans = (ans * n) % MOD;
		n = (n * n) % MOD;
		m >>= 1;
	}
	return ans;
}

int get(int i){
	int a = (MOD + pow_mod(10, i)-1)%MOD;
	return a*pow_mod(9, MOD-2) % MOD;
}

signed main(){

	int n;
	cin >> 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+1];

	d[0] = 0;
	int dp[100010] = {};
	dp[0] = 1;
	for(int x = 0;x < n;x++){
		for(int i = 0;i < 10;i++){
			if((d[x] + i)%9 == d[x+1]){
				if(i == 0){
					dp[x+1] += dp[x];
					dp[x+1] %= MOD;
				}else{
					int num = (MOD+get(r[x])-get(l[x]))%MOD;
					dp[x+1] += dp[x] * num %MOD;
					dp[x+1] %= MOD;
				}
			}

		}
	}
	cout << dp[n] << endl;
	return 0;
}
0