【杭电-oj】-5053-the Sum of Cube(求立方和数学方法)
来源:互联网 发布:中国审美观的变化 知乎 编辑:程序博客网 时间:2024/04/29 08:00
Problem 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].
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
21 32 5
Sample Output
Case #1: 36Case #2: 224
#include<stdio.h>int main(){int n;int m=0;scanf("%d",&n);while(n--){m=m+1;int a,b;__int64 y1=0; //64位的int的输入模式 __int64 y2=0;__int64 y; scanf("%d%d",&a,&b);a=a-1;y1=(b*(b+1))/2;y1=y1*y1; y2=(a*(a+1))/2;y2=y2*y2;y=y1-y2;printf("Case #%d: %I64d\n",m,y);} return 0; }
0 0
- 【杭电-oj】-5053-the Sum of Cube(求立方和数学方法)
- 【杭电oj】5053-the Sum of Cube(立方和)
- 【杭电oj】5053-the Sum of Cube(立方和)
- 【杭电】[5053]the Sum of Cube
- 杭电5053the Sum of Cube
- 【杭电5053】the Sum of Cube
- 【杭电5053】the Sum of Cube
- 【杭电 5053】the Sum of Cube
- HDU 5053 the Sum of Cube(数学求立方和)
- HDOJ 5053 the Sum of Cube (立方和)
- hdoj 5053 the Sum of Cube [数学 立方求和]
- 【 HDUOJ 5053 】 the Sum of Cube 【立方和公式】
- the Sum of Cube 就是立方和
- the sum of cube 立方和
- 杭电Problem 5053 the sum of cube 【数学公式】
- (一):the Sum of Cube(立方和。。。。高效率)
- 杭电acm 5053 the Sum of Cube(简单水题)
- the Sum of Cube
- 世界首例“换头术”将在中国进行中方团队加入
- Ubuntu下安装numpy and matplotlib
- Struts2开始使用convention-plugin实现零配置
- 深度剖析:Android_PullToRefresh
- sublime Text隐藏侧边栏等快捷键
- 【杭电-oj】-5053-the Sum of Cube(求立方和数学方法)
- python 接收C++接口字符串返回值
- java毕向东听课笔记8(多态)
- 世界贸易组织概论
- PHPCMS_数据库配置
- 多值Cookie
- XML与POJO的转换
- RadioButton.check(ChildId()),后执行3次OnCheckedChangeListener的问题
- git里,状态显示有变化,但pull和push时却说Already up-to-date