H - the Sum of Cube(水题)
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(水题)的更多相关文章
- HDU5053the Sum of Cube(水题)
HDU5053the Sum of Cube(水题) 题目链接 题目大意:给你L到N的范围,要求你求这个范围内的全部整数的立方和. 解题思路:注意不要用int的数相乘赋值给longlong的数,会溢出 ...
- Xtreme8.0 - Sum it up 水题
Sum it up 题目连接: https://www.hackerrank.com/contests/ieeextreme-challenges/challenges/sum-it-up Descr ...
- cdoj 80 Cube 水题
Cube Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/80 Descrip ...
- codeforces 577B B. Modulo Sum(水题)
题目链接: B. Modulo Sum time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- poj1564 Sum It Up dfs水题
题目描述: Description Given a specified total t and a list of n integers, find all distinct sums using n ...
- hdoj--5053--the Sum of Cube(水)
the Sum of Cube Time Limit : 2000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Tot ...
- SPOJ 3693 Maximum Sum(水题,记录区间第一大和第二大数)
#include <iostream> #include <stdio.h> #include <algorithm> #define lson rt<< ...
- HDU 4593 H - Robot 水题
H - RobotTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.act ...
- 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 ...
随机推荐
- JSF结合Spring 引入ViewScope
当JSF项目的faceConfig中配置了Spring的配置代码 <application> <el-resolver>org.springframework.web.jsf. ...
- Make 命令
Linux 下 make 命令是系统管理员和程序员用的最频繁的命令之一.管理员用它通过命令行来编译和安装很多开源的工具,程序员用它来管理他们大型复杂的项目编译问题.本文我们将用一些实例来讨论 make ...
- Oracle 存储过程学习笔记
1.存储过程简单实例 CREATE OR REPLACE PROCEDURE 存储过程名称 (参数in,参数out) AS -- 变量声明,每个声明用分号结束.可以在声明的同时初始化 name ); ...
- Python Django框架 补充
Django REST framework ORM框架整理 Django框架 app间互借models字段的操作 ORM数据库操作补充:models中的一对一操作.过滤.事务 Django model ...
- 2016.2.28 DataTable用法汇总
将控件的DataSource转换为DataTable,但是,此控件的DataSource绑定时必须是DataTable,不能是List DataTable dt = (bgvRoutePortion. ...
- Winsock 传输文件
文件传输的原理:发送方把文件读到socket发送端缓冲区中,接收方把socket接收端缓端冲区中的数据写到一个新文件中.当然了,大文件需要循环读写! 服务器端为发送端: #include " ...
- 12-01Js对象##正则表达式##
正则表达式:是一个字符一个字符的验证,通过量词验证字符串: 1.什么是RegExp?RegExp是正则表达式的缩写.RegExp 对象用于规定在文本中检索的内容. 2.定义RegExp:var +变量 ...
- 类型:.net;问题:ASP.NET路由;结果:ASP.NET 路由 .NET Framework 4
ASP.NET 路由 .NET Framework 4 更新:2007 年 11 月 ASP.NET 路由使您可以使用不必映射到网站中特定文件的 URL.由于 URL 不必映射到文件,所以可以在 ...
- H.264学习笔记
1.帧和场的概念 视频的一场或一帧可用来产生一个编码图像.通常,视频帧可以分成两种类型:连续或隔行视频帧.我们平常看的电视是每秒25帧,即每秒更换25个图像,由于视觉暂留效应,所以人眼不会感到闪烁.每 ...
- java中的自动转型的学习理解
java当中的继承是和c++中的继承类似,只是java中的继承时的父类只能有一位. 我们今天在这里讲的是关于java中的自动转型的理解:顾名思义,自动转型值得就是使用时自动的将自身的类型进行转化. 自 ...