Tasks:
 
Task DescriptionDiscussion (0)
Task :: 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.

INPUT:
The 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)

OUTPUT:
For 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
:
:
Available Languages
Task info
Name:O-frequency
Time:1 sec.
Memory:16 MB
#Tests:11
AddedBy: oduleodule
Task Ratings
Difficulty:

4.6 (5 votes)
Quality:

5 (4 votes)
Acceptance Rate
Recent Submissions
Fastest Solutions
UserTime
Punkestain 1.53 s.
crusader 1.62 s.
Mr.Ra16bit 2.04 s.
D.Ostojic 2.04 s.
a180285 2.25 s.
afaji321 2.445 s.
oduleodule 2.625 s.
1010011010 3.135 s.
pedja1 3.51 s.
halil 3.525 s.
Solved By