結果
問題 | No.1086 桁和の桁和2 |
ユーザー |
![]() |
提出日時 | 2020-06-19 23:29:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 101 ms / 3,000 ms |
コード長 | 1,419 bytes |
コンパイル時間 | 785 ms |
コンパイル使用メモリ | 83,644 KB |
実行使用メモリ | 5,888 KB |
最終ジャッジ日時 | 2024-07-22 17:51:40 |
合計ジャッジ時間 | 3,865 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 31 |
ソースコード
#include <iostream>#include <algorithm>#include <iomanip>#include <vector>#include <queue>#include <set>#include <map>using namespace std;typedef long long ll;const ll MOD = 1000000007;template <typename T>T pow(T a, ll n) {T ans = 1;T tmp = a;for (int i = 0; i <= 60; i++) {ll m = (ll)1 << i;if (m & n) {ans *= tmp;ans %= MOD;}tmp *= tmp;tmp %= MOD;}return ans;}ll inv(ll n){if(n == 1) return 1;else return MOD-inv(MOD%n)*(MOD/n)%MOD;}int N;ll L[100000], R[100000], D[100000];int main(){ios::sync_with_stdio(false);cin.tie(0);cout << setprecision(10) << fixed;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];ll ans = 1;int prev = 0;int cnt_plus = 0;for(int i = 0; i < N; i++){if(D[i] == 0){if(cnt_plus > 0){cout << 0 << endl;return 0;}ans = 1;}else{ll r = pow<ll>(10, R[i]);ll l = pow<ll>(10, L[i]);ll d = (r-l+MOD)%MOD;ll tmp = (d*inv(9))%MOD;if(D[i] == prev) tmp++;if(D[i] == 9 && prev == 0 && cnt_plus > 0) tmp++;ans *= tmp;ans %= MOD;cnt_plus++;}prev = D[i];}cout << ans << endl;}