No.2961 Shiny Monster Master
タグ : / 解いたユーザー数 78
作問者 :
Story
I'm currently stuck deep in the shiny-hunting swamp. Please help me.One run takes about $20$ minutes per $1$ cycle...
Problem Statement
A hugely popular monster game has been released. In this game, rare monsters called shinies occasionally appear.
This game uses a counter with a period of $R$ seconds. When the game is started, the counter's value is $0$, and immediately after startup it increases by $1$ every $1$ second. However, once the counter's value reaches $R-1$, it returns to $0$.
It is also known that a shiny always appears when the counter is $A_i(1 \leq i \leq N)$, and does not appear otherwise.
You are now given $Q$ queries. In the $i$-th $(1 \leq i \leq Q)$ query, $l_i,r_i$ are given. Answer the following question.
Input
$R$ $N$ $A_1$ $\cdots$ $A_N$ $Q$ $l_1$ $r_1$ $\ldots$ $l_Q$ $r_Q$
Output
Output $Q$ lines. On the $i(1\leq i \leq Q)$-th line, output the answer to the $i$-th query.
Sample
Sample 1
Input
5 2 1 3 3 1 4 13 20 89 90
Output
2 3 0
In the $2$nd query, at $13$ seconds the counter is $3$ and a shiny appears. At $16$ seconds the counter is $1$, and at $18$ seconds the counter is $3$, so there are $3$ chances in total.
Note that shinies appearing exactly $l_i$ seconds and $r_i$ seconds after starting the game are also included.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。