結果
| 問題 |
No.1086 桁和の桁和2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-19 22:34:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 989 bytes |
| コンパイル時間 | 2,009 ms |
| コンパイル使用メモリ | 195,576 KB |
| 最終ジャッジ日時 | 2025-01-11 07:09:55 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 3 |
| other | AC * 9 WA * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
constexpr int mod = 1000000007;
long long modpow(long long a, long long r) {
long long ret = 1;
while (r) {
if (r & 1) ret = ret * a % mod;
r >>= 1;
a = a * a % mod;
}
return ret;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int N; cin >> N;
vector<long long> L(N), R(N), D(N);
for (auto &x: L) cin >> x;
for (auto &x: R) cin >> x;
for (auto &x: D) cin >> x;
int Dc = 0;
long long Ans = 1;
long long inv9 = modpow(mod-2, 9);
for (int i = 0; i < N && Ans; i++) {
if (D[i] == 0) {
if (Dc != 0) Ans = 0;
continue;
}
int Diff = (D[i] - Dc + 9) % 9;
long long U = (modpow(10, R[i]) - modpow(10, L[i])) * inv9 % mod;
U = (U % mod + mod) % mod;
if (Diff == 0 && Dc != 0) U++;
Dc = D[i];
Ans = Ans * U % mod;
}
cout << Ans << "\n";
return 0;
}