编程介的小学生
2017-11-06 14:57Sum Of Gcd
10Problem Description
Given you a sequence of number a1, a2, ..., an, which is a permutation of 1...n.
You need to answer some queries, each with the following format:
Give you two numbers L, R, you should calculate sum of gcd(a[i], a[j]) for every L <= i < j <= R.
Input
First line contains a number T(T <= 10),denote the number of test cases.
Then follow T test cases.
For each test cases,the first line contains a number n(1<=n<= 20000).
The second line contains n number a1,a2,...,an.
The third line contains a number Q(1<=Q<=20000) denoting the number of queries.
Then Q lines follows,each lines contains two integer L,R(1<=L<=R<=n),denote a query.
Output
For each case, first you should print "Case #x:", where x indicates the case number between 1 and T.
Then for each query print the answer in one line.
Sample Input
1
5
3 2 5 4 1
3
1 5
2 4
3 3
Sample Output
Case #1:
11
4
0
- 点赞
- 回答
- 收藏
- 复制链接分享
1条回答
为你推荐
- 一个比较复杂的排序问题,根据key实现的排序,C语言知识的运用怎么实现
- r语言
- Golang
- erlang
- 1个回答
- 用C语言输出这里的代数问题的结果,关于QSCI
- r语言
- Golang
- erlang
- 1个回答
- GCD,一个数字的生成的问题,有点困难,不会
- lines
- ai
- less
- gcd
- 1个回答
- Mark the Rope
- lines
- gcd
- equals
- color
- 2个回答
- Difference between Triplets
- lines
- as
- each
- 1个回答