A range is given, the begin and the end are both integers. You should sum the cube of all the integers in the range.

InputThe 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].OutputFor 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

首先要明白这一题的题意,就是求一个范围内的所有整数数的立方和

注意:数据范围要用 long long

   求立方和可以用pow函数——>pow(j, 3)

感觉第二个数据错了…………

AC代码

#include<stdio.h>

int solve(int x)
{
return x*x*x;
} int main()
{
int t;
int num = ;
scanf("%d", &t);
while(t--)
{
int a, b;
long long sum = ; scanf("%d %d", &a, &b);
for(int i = a; i <= b; i++)
{
sum += solve(i);
}
num++;
printf("Case #%d: %lld\n", num, sum);
}
return ;
}

H - the Sum of Cube(水题)的更多相关文章

  1. HDU5053the Sum of Cube(水题)

    HDU5053the Sum of Cube(水题) 题目链接 题目大意:给你L到N的范围,要求你求这个范围内的全部整数的立方和. 解题思路:注意不要用int的数相乘赋值给longlong的数,会溢出 ...

  2. Xtreme8.0 - Sum it up 水题

    Sum it up 题目连接: https://www.hackerrank.com/contests/ieeextreme-challenges/challenges/sum-it-up Descr ...

  3. cdoj 80 Cube 水题

    Cube Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/80 Descrip ...

  4. codeforces 577B B. Modulo Sum(水题)

    题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  5. poj1564 Sum It Up dfs水题

    题目描述: Description Given a specified total t and a list of n integers, find all distinct sums using n ...

  6. hdoj--5053--the Sum of Cube(水)

    the Sum of Cube Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Tot ...

  7. SPOJ 3693 Maximum Sum(水题,记录区间第一大和第二大数)

    #include <iostream> #include <stdio.h> #include <algorithm> #define lson rt<< ...

  8. HDU 4593 H - Robot 水题

    H - RobotTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.act ...

  9. HDU 4788 Hard Disk Drive (2013成都H,水题)

    Hard Disk Drive Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

随机推荐

  1. 免费的xshell下载

    平时从网站上下载的xshell,都是有有效期的,用一个月就生效了 所以我们可以这样: 学习源头: https://blog.csdn.net/zhoukikoo/article/details/794 ...

  2. Java基础--压缩和解压缩gz包

    gz是Linux和OSX中常见的压缩文件格式,下面是用java压缩和解压缩gz包的例子 public class GZIPcompress { public static void FileCompr ...

  3. Hybrid App混合模式移动应用开发(AngularJS+Cordova+Ionic)

    以前公司开发了某手机APP是通过jquerymobile来实现的,发现它对手机上的原生设备无能为力.于是在下一个项目到来之际,通过筛选最终决定使用cordova+Ionic.看起来简单,但是因为他们各 ...

  4. Oracle session出现大量的inactive

    一.官网说明 1.1 processes 11gR2 的文档: Property Description Parameter type Integer Default value 100 Modifi ...

  5. 管理linked break-off snapshot

    1. 建立linked break-off snapshot   (1) 建立原卷 #> vxassist -g APS2_AFC_DG make vol1 4096000 #> vxpr ...

  6. DDD学习笔录——简介DDD的战术模式、问题空间和解空间

    DDD的战术模式 DDD的战术模式(也称为模型构造块)是一个帮助创建 用于复杂有界上下文的有效模型的 模式集合. 也就是我们常说的设计模式. 问题空间 问题空间将问题域提炼成更多可管理的子域,是真对于 ...

  7. linux命令-passwd

    修改密码 #passwd 新密码 重新输入密码 #passwd dennywang  ////命令+用户名 ////////////////////////////////////////////// ...

  8. JMS编程模型

    (1) ConnectionFactory创建Connection对象的工厂,针对两种不同的jms消息模型,分别有QueueConnectionFactory和TopicConnectionFacto ...

  9. TypeError: 'append' called on an object that does not implement interface FormData 解决方法

    使用ajax提交form表单时,$("formId").serialize()不能提交type="file"类型的input,这个时候可以选择使用FormDat ...

  10. Vim 配置文件===/etc/vimrc

    1.替换方法 替换对应的vimrc文件,定制自己的vimrc /etc/vimrc              替换此文件: /home/lmy/.vimrc     只对当前用户有效: Ubuntu9 ...