AtCoder Beginner Contest 129
F
Takahashi's Basics in Education and Learning
AtCoder
⌀ 2621
原题
← E→
翻译中…

Problem Statement

翻译中…

There is an arithmetic progression with $L$ terms: $s_0, s_1, s_2, ... , s_{L-1}$.

翻译中…

The initial term is $A$, and the common difference is $B$. That is, $s_i = A + B \times i$ holds.

翻译中…

Consider the integer obtained by concatenating the terms written in base ten without leading zeros. For example, the sequence $3, 7, 11, 15, 19$ would be concatenated into $37111519$. What is the remainder when that integer is divided by $M$?

翻译中…

Constraints

翻译中…
  • All values in input are integers.
  • $1 \leq L, A, B < 10^{18}$
  • $2 \leq M \leq 10^9$
  • All terms in the arithmetic progression are less than $10^{18}$.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

L A B M

翻译中…

Output

翻译中…

Print the remainder when the integer obtained by concatenating the terms is divided by $M$.

翻译中…

样例

Input #1
5 3 4 10007
Output #1
5563
Our arithmetic progression is $3, 7, 11, 15, 19$, so the answer is $37111519$ mod $10007$, that is, $5563$.
Input #2
4 8 1 1000000
Output #2
891011
Input #3
107 10000000000007 1000000000000007 998244353
Output #3
39122908
题目信息
题号
abc129_f
时间限制
3 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。