the Sum of Cube hd 5053
Description
A range is given, the begin and the end are both integers. You should sum the cube of all the integers in the range.
Input
The 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].
Output
For 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 5
Sample Output
Case #1: 36
A range is given, the begin and the end are both integers. You should sum the cube of all the integers in the range.
Input
The 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].
Output
For 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 5
Sample Output
Case #1: 36
Case #2: 224
#include<stdio.h>
int main()
{
int i,a,b,n;
int cas=0;
__int64 sum;
scanf("%d",&n);
while(n--)
{
cas++;
sum=0;
scanf("%d%d",&a,&b);
for(i=a;i<=b;i++)
{
sum+=(__int64)i*i*i;
}
printf("Case #%d: %I64d\n",cas,sum);
}
return 0;
}
相關文章
- Kylin建立Cube
- Cube 技術解讀 | Cube 小程式技術詳解
- Cube 技術解讀 | Cube 卡片技術棧詳解
- Cube 技術解讀 | Cube 渲染設計的前世今生
- 7.68 CUBE_TABLE
- Oracle OCP(12):ROLLUP & CUBEOracle
- cube+sd+fatfs+freertos
- 秒殺 2Sum 3Sum 4Sum 演算法題演算法
- GCD SUMGC
- Sum Problem
- 集合sum
- 15+18、3Sum 4Sum
- Cube-UI 最近做的更新UI
- leetcode Sum系列LeetCode
- Sum of Left Leaves
- Path-sum
- Path Sum III
- Leetcode Path SumLeetCode
- B - Minimum Sum
- Range Minimum Sum
- Missing Subsequence Sum
- Picture hd 2052
- Apache Kylin 入門 5 - 構建 CubeApache
- Apache Kylin 入門 6 - 優化 CubeApache優化
- Apache Kylin 入門 5 – 構建 CubeApache
- cube ui RecycleList 不自動追加資料UI
- Leetcode 39 Combination SumLeetCode
- md5sum
- 112-Path Sum
- Leetcode 1 two sumLeetCode
- 7.22 APPROX_SUMAPP
- LeetCode | 1 Two SumLeetCode
- SQL groupby sum 用法SQL
- 密碼 hd 2043密碼
- Big Number hd 1212
- 不要62 hd 2089
- 解析數倉OLAP函式:ROLLUP、CUBE、GROUPING SETS函式
- leetcode-39-Combination SumLeetCode