Garv and Lottery Tickets
All submissions for this problem are available.There are $N$ lottery tickets with numbers written on them. Garv wants to buy some lottery tickets, but he is kind of superstitious. He has a lucky digit $X$, and he wants you to answer $Q$ queries before he buys the tickets. Each query will contain 2 numbers $L$ and $R$. You will need to output the sum of occurrences of the digit $X$ in the numbers between positions $L$ and $R$ (both inclusive) ###Input: - The first line consists of $N$, $Q$, $X$ respectively. - Second line consists of $N$ numbers. - The next $Q$ lines consist of a query on each line with $L$ and $R$. ###Output: - For each query output a single number, the sum of occurrences from $L$ to $R$ in the given query in a new line. ###Constraints - $1 \leq N \leq 10^5$ - $1 \leq Q \leq 10^5$ - $1 \leq L \leq R \leq N$ - $0 \leq X \leq 9$ - $0 \leq A_i \leq 10$$18$ ###Subtasks - 30 points: - $1 \leq N \leq 10^2$ - $1 \leq Q \leq 10^2$ - $0 \leq A_i \leq 10^3$ - 70 points : Original Constraints ###Sample Input: 4 2 3 23 43 21 32 1 4 2 3 ###Sample Output: 3 1 ###EXPLANATION: For the first query, you add occurrences of 3 in all the elements from 1 to 4, which gives 3 For the second query you add occurrences of 3 in second and third element which is 1+0=1
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, SQL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, R, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.