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. Poj 2367 Genealogical tree(拓扑排序)

    题目:火星人的血缘关系,简单拓扑排序.很久没用邻接表了,这里复习一下. import java.util.Scanner; class edge { int val; edge next; } pub ...

  2. Day3-Python基础3---函数介绍

    一.函数基本语法及特性 函数是什么? 函数一词来源于数学,但编程中的「函数」概念,与数学中的函数是有很大不同的,具体区别,我们后面会讲,编程中的函数在英文中也有很多不同的叫法.在BASIC中叫做sub ...

  3. java代码。从来没想过java里的继承是多么的难懂。如哲学

    总结:实例.. 这里不加super("aaa",32); 运行:父类和子类的姓名,年龄是一样的.那这个super为什么没效果呢? 显示:class:Ji姓名是 小红年龄是:20课程 ...

  4. altium designer 中器件原理图库中,将一个器件分成几部分是如何操作的?就是如何用part表示?

    在SCH Library的Components中选中你要添加part的器件,tools菜单--new part即可

  5. PDM生成数据库-0设置表名和字段名中不带双引号

    如果PDM直接导出脚本的话,所有的表和字段都会被加上双引号,非常不方便,去除双引号的办法: Database->Edit Current DBMS在弹出窗体中第一项General中找到 Scri ...

  6. PowerDesigner中添加约束

    唯一约束 唯一约束与创建唯一索引基本上是一回事,因为在创建唯一约束的时候,系统会创建对应的一个唯一索引,通过唯一索引来实现约束.不过唯一约束更直观的表达了对应列的唯一性,使得对应索引的目的更加清晰,所 ...

  7. java 多线程系列---JUC原子类(五)之AtomicLongFieldUpdater原子类

    AtomicLongFieldUpdater介绍和函数列表 AtomicLongFieldUpdater可以对指定"类的 'volatile long'类型的成员"进行原子更新.它 ...

  8. 11-10SQLserver基础--数据库之视图

    视图 视图实际就是对表的连接展现出来的结果建成的虚拟表.简单来说,视图实际上就是一个虚拟的表,通过表与表之间的关系连接起来,方便查询时使用. 首先,将需要连接的语句存储到数据库中,定义新的视图名代替连 ...

  9. eclipse中的TODO和FIXME

    最近使用eclipse开发代码时,公司要求按他们制定代码规范编写代码,其他都还好,因为基本都养成良好习惯了,但TODO和FIXME就有点陌生,查了一下资料,发现笔者寡闻了,果然学海无涯,好了,下边解释 ...

  10. .net 4 安装未成功,无意中的解决办法!

    公司 电脑是chost的系统,由于使用时间过长,重装纯净版系统的话,代价太大,故网上寻求各种解决办法! 安装.net 4 总是失败,查看百度,各种: WIN7系统哈哈跟我的问题一样,我的刚才解决了:1 ...