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: ...
随机推荐
- ofbiz初级教程
本教程是ofbiz 基本应用,它涵盖了OFBiz应用程序开发过程的基本原理.目标是使开发人员熟悉最佳实践,编码惯例,基本控制流程以及开发人员对OFBiz定制所需的所有其他方面. 本教程将帮助您在OFB ...
- POJ 2773
不经意看见dis后的“mod”一词后,瞬间有了思路,点进去看,却发现别人想的和我的不一样——! 我是这样想的,利用的是剩余系+欧几里德带余除法的性质. 若两者GCD=1,则必有除数和余数GCD=1.于 ...
- php给图片加入文字水印
PHP对图片的操作用到GD库.这里我们介绍怎样给图片加入文字水印. 大致分为四步: 1.打开图片 2.操作图片 3.输出图片 4.销毁图片 以下我们上代码来详细解说每步的实现过程: <? php ...
- [iOS]字符串转字典
有点时候,我们json中有post请求的网址,这个时候我们须要把网址字符串转换成body体 字典 放在post请求中 NSString *body = [self.url_C_ component ...
- Mysql 数据迁移后 启动出错
今天上班后不知道为什么,mysql一直无法启动,折腾了半天于是决定重装 我本地的server用的是wamp , 重装的时候, 要进行数据备份 , 我使用的最简单粗暴的备份方式, 就是直接进入到mysq ...
- 最全Pycharm教程(29)——再探IDE,速成手冊
1.准备工作 (1)确认安装了Python解释器,版本号2.4到3.4均可. (2)注意Pycharm有两个公布版本号:社区版和专业版,详见 Edition Comparison Matrix 2.初 ...
- 343D/Codeforces Round #200 (Div. 1) D. Water Tree dfs序+数据结构
D. Water Tree Mad scientist Mike has constructed a rooted tree, which consists of n vertices. Each ...
- Handler.post与View.post的区别
Android的线程分UI线程与非UI线程两类.而Handler是非UI线程向UI线程传递消息的桥梁. 除了非常常用sendMessage之外,Handler也提供了post(Runnable...) ...
- 138.安全退出的异常,要用throw 尽量不用exit(0)
#include<iostream> #include<cstdlib> using namespace std; ////非安全退出,结束进程, //C++ 必须释放对象,最 ...
- calender怎么获取每周的周日(给每周的周日特定时间点设置定时)
获取每周的周日 //如果是周日,特殊处理.老外的周日-周六为一周 calendarTemp.add(Calendar.WEEK_OF_MONTH,1); calendarTemp.set(Calend ...