O-frequency
Number NIZ-N is a number created when you write, one after another, all numbers from one to N.
For a known number N determine how many times number K is repeated in NIZ-N.
InputThe first row contains two integers N and R separated by an empty space.
Each of the next R rows contain one integer Ki. ( 1<= N <= 200 000 ; 1<= R <= 500 000 ; 0<= Ki < 1 000 000)
Each of the next R rows contain one integer Ki. ( 1<= N <= 200 000 ; 1<= R <= 500 000 ; 0<= Ki < 1 000 000)
OutputFor every number Ki given in the input, you need to output its frequency in NIZ-N (number of times it appears in NIZ-N).
Input:
20 5
0
15
101112
12
1
Output:
2
1
1
2
12
Niz-20 is 1234567891011121314151617181920
Number 0 appears two times.Around the middle and on end
Number 15 appears only ones. Around 2/3 of NIZ-N
Number 101112 appears only ones. Arround half of NIZ-N.
Number 12 appears two times. At the beginning and around the middle.
Number 1 appears 12 times.
Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.