1415 - How many seats
Time Limit : 1 Second
Memory Limit : 128 MB
As we all know the winter vacation is coming soon, so train tickets are becoming hot again! (You can see the long waiting line in front of the tickets office). Fortunately our lucky xiaoY has got a ticket back home, but Mr HH who gave xiaoY the ticket placed a hard problem at the same time. Because Mr HH was working on the CRH(和谐号), he needed to know how many seats the CRH could be sold. CRH is designed in a strange way.
1st: The carriage of index i has the sum of i's all digital seats.
2nd: From the beginning of the train every 5 carriage is forbidden to take passenger.
3rd: Give you the index of head-----L, and index of tail-----R, calculate the number of seats could be sold!
Mr HH was tired of this hard math problem, so he turned this problem to xiaoY, Can you help xiaoY solve this problem to back home!
N ---- Case number (N<=100)
N pair of number followed
L, R ---- head and tail of train. (0=< L<=R<=100000000)
Sum ----- the total seats of CRH could be sold.
- sample input
3 3 5 8 13 1 10
- sample output
12 24 40
3 + 4 + 5 = 12
8 + 9 + (1+0) + (1+1) + (1+3) = 24 (the 5th number 12 is ignored)
1 + 2 + 3 + 4 + 6 + 7 + 8 + 9 = 40 (the 5th number 5 and the 10th number 10 are ignored)
- He Jian, HUST Campus 2010, Preliminary