結果

問題 No.1086 桁和の桁和2
ユーザー tnakao0123tnakao0123
提出日時 2020-06-22 00:22:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 155 ms / 3,000 ms
コード長 1,426 bytes
コンパイル時間 781 ms
コンパイル使用メモリ 91,840 KB
実行使用メモリ 5,576 KB
最終ジャッジ日時 2023-09-30 00:03:31
合計ジャッジ時間 5,098 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 46 ms
5,348 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 29 ms
4,624 KB
testcase_11 AC 9 ms
4,380 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 36 ms
4,904 KB
testcase_14 AC 24 ms
4,432 KB
testcase_15 AC 20 ms
4,384 KB
testcase_16 AC 109 ms
4,852 KB
testcase_17 AC 10 ms
4,376 KB
testcase_18 AC 151 ms
5,576 KB
testcase_19 AC 124 ms
5,024 KB
testcase_20 AC 16 ms
4,376 KB
testcase_21 AC 107 ms
5,048 KB
testcase_22 AC 149 ms
5,368 KB
testcase_23 AC 92 ms
4,672 KB
testcase_24 AC 64 ms
4,376 KB
testcase_25 AC 126 ms
5,112 KB
testcase_26 AC 104 ms
4,852 KB
testcase_27 AC 76 ms
4,380 KB
testcase_28 AC 62 ms
4,384 KB
testcase_29 AC 70 ms
4,376 KB
testcase_30 AC 154 ms
5,468 KB
testcase_31 AC 154 ms
5,488 KB
testcase_32 AC 155 ms
5,536 KB
testcase_33 AC 154 ms
5,472 KB
testcase_34 AC 154 ms
5,468 KB
testcase_35 AC 46 ms
5,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 1086.cc:  No.1086 桁和の桁和2 - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MOD = 1000000007;

/* typedef */

typedef long long ll;

/* global variables */

ll ls[MAX_N], rs[MAX_N];
int ds[MAX_N];

/* subroutines */

inline int powmod(int a, ll n) {  // a^n % MOD
  int pm = 1;
  while (n > 0) {
    if (n & 1) pm = (ll)pm * a % MOD;
    a = (ll)a * a % MOD;
    n >>= 1;
  }
  return pm;
}

inline int fcs(ll n) {
  return (ll)(powmod(10, n) + MOD - 1) % MOD * powmod(9, MOD - 2) % MOD;
}

/* main */

int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) scanf("%lld", ls + i);
  for (int i = 0; i < n; i++) scanf("%lld", rs + i);
  for (int i = 0; i < n; i++) scanf("%d", ds + i);

  int ans = 1, pd = 0;
  for (int i = 0; i < n; i++) {
    if (ds[i] == 0) {
      if (pd != 0) {
	puts("0");
	return 0;
      }
    }
    else {
      int fc = (fcs(rs[i]) + MOD - fcs(ls[i])) % MOD;
      if (pd == ds[i]) fc++;
      else pd = ds[i];
      ans = (ll)ans * fc % MOD;
    }
  }

  printf("%d\n", ans);
  return 0;
}
0