the Sum of Cube hd 5053
2016-07-20 16:01
411 查看
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
Case #2: 224
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; }
相关文章推荐
- ImageView的背景图片与R.drawable.xx比较
- HDOJ 1997 汉诺塔VII 【递归】
- 矩阵原地转置,空间复杂度为O(1)(暂时先保存下来)
- Android静态安全检测 -> 日志泄漏风险
- Codeforces Round #363 (Div. 2) A
- 【Intellij】导入 jar 包
- 最小生成树(kruskal)
- rtrim函数的一个坑
- 黑马程序员: PHP零基础土木研究生,如何做到毕业年薪20万?
- javascript多个圆点弧线运动效果
- 深入理解Java的接口与抽象类
- 程序员的八个级别-拿来分享下
- jersey+grizzly学习笔记
- PowerShell提示,因为此系统中禁止执行脚本
- Java 操作Oracle数据库(建表,插数据,删除)
- 软件开发不可与建筑类比
- [LeetCode] 37. Sudoku Solver
- URI和URL的区别(转载)
- [leetcode]229. Majority Element II
- web中spring与jpa整合