HPU专题训练(-1)GCD&&素筛&&快速幂_____I - the Sum of Cube
A range is given, the begin and the end are both integers. You should sum the cube of all the integers in the range.
InputThe first line of the input is T(1 <= T <= 1000), which stands for the number of test cases you need to solve.
Each case of input is a pair of integer A,B(0 < A <= B <= 10000),representing the range[A,B].OutputFor each test case, print a line “Case #t: ”(without quotes, t means the index of the test case) at the beginning. Then output the answer – sum the cube of all the integers in the range.Sample Input
2 1 3 2 5Sample Output
Case #1: 36 Case #2: 224
/*
计算范围内的立方和
*/
#include<stdio.h>
int main()
{
int t;
scanf("%d",&t);
for(int j=1;j<=t;j++)
{
long long int a,b,sum=0;
scanf("%lld %lld",&a,&b);
for(long long int i=a;i<=b;i++)
{
sum+=i*i*i;
}
printf("Case #%d: %lld\n",j,sum);
}
return 0;
}