AtCoder Regular Contest 166
翻译中…
Problem Statement
翻译中…
You are given an integer sequence $A=(A_1,\ldots,A_N)$ and positive integers $a$, $b$, and $c$.
翻译中…
You can perform the following operation on this sequence any number of times, possibly zero.
翻译中…
- Choose an integer
$i$such that$1\leq i\leq N$. Replace$A_i$with$A_i+1$.
翻译中…
Your objective is to make the sequence $A$ contain at least one multiple of $a$, at least one multiple of $b$, and at least one multiple of $c$. Find the minimum number of operations required to achieve this objective.
翻译中…
Constraints
翻译中…
$1\leq N\leq 2\times 10^5$$1\leq a, b, c \leq 10^6$$1\leq A_i\leq 10^{18}$
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
N a b c
A_1 \cdots A_N
翻译中…
Output
翻译中…
Print the minimum number of operations required to achieve the objective.
翻译中…
样例
Input #1
3 3 4 5
8 9 11
Output #1
2
You can perform the operation twice so that $A = (8,10,12)$ to achieve the objective.
Input #2
3 3 4 5
14 11 59
Output #2
1
You can perform the operation once so that $A = (14,11,60)$ to achieve the objective.
Input #3
6 10 20 30
8 17 5 28 39 13
Output #3
3
You can perform the operation three times so that $A = (8,17,5,30,40,13)$ to achieve the objective.
Input #4
1 999997 999998 999999
123456789123456789
Output #4
876537210887543205
You can perform the operation $876537210887543205$ times so that $A = (999994000010999994)$ to achieve the objective.
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。