hdu 5053 (2014上海网赛L题 求立方和)

题目大意:给你L到N的范围,要求你求这个范围内的所有整数的立方和。

Sample Input
2 //T
1 3
2 5

Sample Output
Case #1: 36
Case #2: 224

 

 1 # include <iostream>
 2 # include <cstdio>
 3 # include <cstring>
 4 # include <algorithm>
 5 # include <cmath>
 6 # define LL long long
 7 using namespace std ;
 8 
 9 int main ()
10 {
11     //freopen("in.txt","r",stdin) ;
12     int T ;
13     cin>>T ;
14     int Case = 0 ;
15     while(T--)
16     {
17         Case++ ;
18         LL a , b ;
19         cin>>a>>b ;
20         LL i  , sum = 0 ;
21         for (i = a ; i <= b ; i++)
22             sum += i*i*i ;
23         cout<<"Case #"<<Case<<": "<<sum<<endl ;
24     }
25 
26     return 0 ;
27 }
View Code

 

posted @ 2015-07-20 20:07  __Meng  阅读(188)  评论(0编辑  收藏  举报