問題一覧 > 通常問題

No.1086 桁和の桁和2

レベル : / 実行時間制限 : 1ケース 3.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 82
作問者 : tyawanmusi / テスター : QCFium
お気に入りにしたユーザー ProblemId : 3825 / 自分の提出
問題文最終更新日: 2020-06-19 17:40:04
Digit Sum of Digit Sum 2
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
yukicoder contest 253 (順位表) の他の問題:

Problem Statement

Define the function $f(X)$ as follows.
$f(X) = \left\{ \begin{array}{ll} X & (X < 10) \\ f(Xの桁和) & (10 \le X)\end{array} \right.$
An integer sequence $A$ with $N$ elements that satisfies the following conditions is called a "beautiful sequence".

  • For all $i(1 \le i \le N)$, $10^{L_i} \le A_i < 10^{R_i}$ or $A_i = 0$
  • For all $i(1 \le i \le N)$, $f(f(A_1) + f(A_2) + \dots + f(A_i)) = D_i$
You are given an integer $N$ and integer sequences $L, R, D$.
Find the total number of "beautiful sequences", modulo $10^9+7$.

Constraints

  • $1 \le N \le 10^5$
  • $0 \le L_i < R_i \le 10^{18}$
  • $0 \le D_i \le 9$
  • $N, L_i, R_i, D_i$ are integers

Input

$N$
$L_1 \ L_2 \dots L_N$
$R_1 \ R_2 \dots R_N$
$D_1 \ D_2 \dots D_N$

The first line contains the integer $N$.
The second line contains the integer sequence $L$, separated by spaces.
The third line contains the integer sequence $R$, separated by spaces.
The fourth line contains the integer sequence $D$, separated by spaces.

Output

Output the total number of "beautiful sequences", modulo $10^9+7$.
Print a newline at the end.

Sample

Sample 1
Input
2
0 1
1 2
3 4
Output
10

Examples of "beautiful sequences" include $(3,10),(3,55)$.

This input means that the following hold:

  • $1 \le A_1 < 10$ or $A_1 = 0$
  • $10 \le A_2 < 100$ or $A_2 = 0$
  • $f(f(A_1))=3$
  • $f(f(A_1)+f(A_2))=4$

Sample 2
Input
5
8 13 21 34 55
89 144 233 377 610
1 1 2 3 5
Output
880448910

Find the total number of "beautiful sequences", modulo $10^9+7$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。