Descriptiona 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 was T (1 <= t <=), which stands for the number of test cases you need to solve.
Each case of input is a pair of integer A, a (0 < a <= B <= 10000), representing the range[a,b]. Outputfor, 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 the integers in the range. Sample Input21 5 Sample Outputcase #1:36Case #2:224
1#include <cstdio>2__int64 a[1000000]={0,1};3 intMain ()4 {5 for(__int64 i=1; i<=1000000; i++)6 {7a[i]=a[i-1]+i*i*i;8 }9__int64 t,k=0;;Tenscanf"%i64d",&t); One while(t--) A { - __int64 m,n; -scanf"%i64d%i64d",&m,&n); theprintf"Case #%i64d:%i64d\n", ++k,a[n]-a[m-1]); - } -}
Hangzhou Electric 5053 The Sum of the cube (for the cubic and in the interval) to play the table method