HDU5053the Sum of Cube(水题)
HDU5053the Sum of Cube(水题)
题目大意:给你L到N的范围,要求你求这个范围内的全部整数的立方和。
解题思路:注意不要用int的数相乘赋值给longlong的数,会溢出。
代码:
#include <cstdio>
#include <cstring>
const int N = 10005;
typedef long long ll;
ll t[N];
void init () {
for (ll i = 1; i <= N - 5; i++)
t[i] = i * i * i;
}
int main () {
int T;
int A, B;
scanf ("%d", &T);
init();
for (int i = 1; i <= T; i++) {
scanf ("%d%d", &A, &B);
ll sum = 0;
for (int j = A; j <= B; j++)
sum += t[j];
printf ("Case #%d: %I64d\n", i, sum);
}
return 0;
}
HDU5053the Sum of Cube(水题)的更多相关文章
- cdoj 80 Cube 水题
Cube Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/80 Descrip ...
- Xtreme8.0 - Sum it up 水题
Sum it up 题目连接: https://www.hackerrank.com/contests/ieeextreme-challenges/challenges/sum-it-up Descr ...
- H - the Sum of Cube(水题)
A range is given, the begin and the end are both integers. You should sum the cube of all the intege ...
- 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 ...
- hdu----(5053)the Sum of Cube(签到题,水体)
the Sum of Cube Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- SPOJ 3693 Maximum Sum(水题,记录区间第一大和第二大数)
#include <iostream> #include <stdio.h> #include <algorithm> #define lson rt<< ...
- ACM水题
ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...
随机推荐
- 获取ip,判断用户所在城市
PHP获取IP地址 这个比较简单了,利用PHP自带函数就可以了,PHP中文手册看一下,都有现成的例子,就不过多说明了,直接上代码,A段: <? //PHP获取当前用户IP地址方法 $xp_Use ...
- Android程序之全国天气预报查询(聚合数据开发)
一.项目演示效果例如以下: 项目源码下载地址: http://pan.baidu.com/s/1pL6o5Mb password:5myq 二.使用 聚合数据SDK: (1)聚合数据官网地址:http ...
- @crossorigin注解跨域
在@controller中类的头部有一个@CrossOrigin注解. @CrossOrigin是用来处理跨域请求的注解 先来说一下什么是跨域: (站在巨人的肩膀上) 跨域,指的是浏览器不能执行其他网 ...
- hive 运行sqlclient异常
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. java.lang.Runtim ...
- hdu1213 How Many Tables(并查集)
How Many Tables Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- UVALive 4225 / HDU 2964 Prime Bases 贪心
Prime Bases Problem Description Given any integer base b >= 2, it is well known that every positi ...
- zzulioj--1790-- 弹珠游戏(数学水题!)
弹珠游戏 Time Limit: 1 Sec Memory Limit: 128 MB Submit: 14 Solved: 10 SubmitStatusWeb Board Descriptio ...
- vue2 filter过滤器的使用
本章主要讲vue2的过滤器的使用 1.先介绍下vue1与vue2的filter区别,也就是vue2更新的地方 a: 2.0将1.0所有自带的过滤器都删除了,也就是说,在2.0中,要使用过滤器,则需要我 ...
- Linux换行符相关
Linux和windows中的换行符差异问题LINUX的换行符在Windows记事本打开不换行或出现黑点是由于Linux和windows中的换行符差异问题造成的. Unix系统里,每行结尾只有“< ...
- Django(1.7 part1)
django安装: django解压后目录下有一个setup.py文件,在命令行运行python setup.py install,当前前提是已经安装了python才能执行命令,然后用下面命令检查dj ...