結果

問題 No.1086 桁和の桁和2
ユーザー QCFiumQCFium
提出日時 2020-06-15 22:24:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 69 ms / 3,000 ms
コード長 1,098 bytes
コンパイル時間 1,285 ms
コンパイル使用メモリ 165,428 KB
実行使用メモリ 5,600 KB
最終ジャッジ日時 2023-09-29 23:43:18
合計ジャッジ時間 4,289 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 66 ms
5,600 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 44 ms
4,628 KB
testcase_11 AC 12 ms
4,380 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 56 ms
4,948 KB
testcase_14 AC 33 ms
4,516 KB
testcase_15 AC 9 ms
4,376 KB
testcase_16 AC 48 ms
4,824 KB
testcase_17 AC 5 ms
4,380 KB
testcase_18 AC 68 ms
5,392 KB
testcase_19 AC 55 ms
5,024 KB
testcase_20 AC 8 ms
4,380 KB
testcase_21 AC 47 ms
4,816 KB
testcase_22 AC 67 ms
5,384 KB
testcase_23 AC 41 ms
4,856 KB
testcase_24 AC 29 ms
4,376 KB
testcase_25 AC 55 ms
5,084 KB
testcase_26 AC 49 ms
4,708 KB
testcase_27 AC 35 ms
4,424 KB
testcase_28 AC 30 ms
4,408 KB
testcase_29 AC 33 ms
4,376 KB
testcase_30 AC 68 ms
5,480 KB
testcase_31 AC 67 ms
5,424 KB
testcase_32 AC 67 ms
5,500 KB
testcase_33 AC 69 ms
5,452 KB
testcase_34 AC 67 ms
5,364 KB
testcase_35 AC 69 ms
5,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

#define MOD 1000000007

int mpow(int a, int64_t b) {
	b %= 1000000006;
	int res = 1;
	for (; b; b >>= 1) {
		if (b & 1) res = (int64_t) res * a % MOD;
		a = (int64_t) a * a % MOD;
	}
	return res;
}

int main() {
	int n = ri();
	int64_t l[n], r[n];
	int d[n];
	for (auto &i : l) scanf("%" SCNd64, &i);
	for (auto &i : r) scanf("%" SCNd64, &i);
	for (auto &i : d) i = ri();
	
	int head = 0;
	while (head < n && !d[head]) head++;
	
	int pow10[31] = { 10 };
	for (int i = 0; i < 30; i++) pow10[i + 1] = (int64_t) pow10[i] * pow10[i] % MOD;
	auto mpow10 = [&] (int64_t b) {
		b %= 1000000006;
		int res = 1;
		for (int i = 0; b; b >>= 1, i++) if (b & 1) res = (int64_t) res * pow10[i] % MOD;
		return res;
	};
	
	int res = 1;
	for (int i = head; i < n; i++) {
		if (!d[i]) res = 0;
		int diff = (d[i] - (i ? d[i - 1] : 0)) % 9;
		int times = (!diff && i != head) + (int64_t) (mpow10(r[i]) - mpow10(l[i])) * 111111112 % MOD;
		res = (int64_t) res * times % MOD;
	}
	if (res < 0) res += MOD;
	printf("%d\n", res);
	return 0;
}

0