The 7th(2012) ACM Programming Contest of HUST - Preliminary Contest
From: 2012-11-17 12:00:00
To: 2012-11-17 17:00:00
Now: 2017-09-22 06:50:20
C - Shepherd
Time Limit: 2s
Memory Limit: 64MB
Submissions: 513 Solved: 85
- Hehe keeps a flock of sheep, numbered from 1 to n and each with a weight wi. To keep the sheep healthy, he prepared some training for his sheep. Everytime he selects a pair of numbers (a,b), and chooses the sheep with number a, a+b, a+2b, … to get trained. For the distance between the sheepfold and the training site is too far, he needs to arrange a truck with appropriate loading capability to transport those sheep. So he wants to know the total weight of the sheep he selected each time, and he finds you to help him.
- There’re several test cases. For each case:
The first line contains a positive integer n (1≤n≤10^5)---the number of sheep Hehe keeps.
The second line contains n positive integer wi(1≤n≤10^9), separated by spaces, where the i-th number describes the weight of the i-th sheep.
The third line contains a positive integer q (1≤q≤10^5)---the number of training plans Hehe prepared.
Each following line contains integer parameters a and b (1≤a,b≤n)of the corresponding plan.
- For each plan (the same order in the input), print the total weight of sheep selected.
- Sample Input
1 2 3 4 5
- Sample Output
- Problem Setter : Zhou Zhou