結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,456 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 201 ms
6,468 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,400 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 126 ms
5,652 KB
testcase_11 AC 35 ms
4,528 KB
testcase_12 AC 9 ms
4,380 KB
testcase_13 AC 159 ms
5,972 KB
testcase_14 AC 101 ms
5,484 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 202 ms
6,736 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++){
			int num = d[x] + i % 9;
			if(num == 0 && (d[x] != 0 || i != 0)){
				num = 9;
			}
			if(num == 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