天天看點

【水題】HDU 5053 the Sum of Cube

求以邊長[A,B](閉區間) 的立方體的體積和

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <cmath>
using namespace std;
#include <queue>
#include <stack>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <time.h>;
#define cler(arr, val)    memset(arr, val, sizeof(arr))
#define IN     freopen ("in.txt" , "r" , stdin);
#define OUT  freopen ("out.txt" , "w" , stdout);
typedef long long  LL;
const int MAXN = 710;//點數的最大值
const int MAXM = 200006;//邊數的最大值
const int INF = 0x3f3f3f3f;
const int mod = 10000007;
const int N=102010;
int main()
{
    int t,cas=1;
    cin>>t;
    while(t--)
    {
        LL sum=0,a,b;
        cin>>a>>b;
        for(LL i=a;i<=b;i++)
            sum+=i*i*i;
        printf("Case #%d: ",cas++);
        cout<<sum<<endl;
    }
}