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: ...
随机推荐
- CSS3特效——六面体
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- 06001_NoSQL概述
1.什么是NoSQL? NoSQL(NoSQL=Not Only SQL),意即“不仅仅是SQL”,是一项全新的数据库理念,泛指非关系型的数据库. 2.关于关系型数据库和nosql数据库 (1)关系型 ...
- JSON数据的生成与解析
JSON数据的生成与解析.首先先到网上下载一个json jar包,我用的是org.json 演示样例代码: package json; import org.json.JSONArray; impor ...
- oracle 11g sql developer安装后无法使用
oracle11g安装后出现 再去官网单独下来个sql developer安装 sql developer须要jre支持
- html页面的简单对话框(alert, confirm, prompt)
html页面简单的三种对话框例如以下: 1.alert(),最简单的提示框: alert("你好!"); 2.confirm(),有确认和取消两个button: if(confir ...
- Python入门机器学习
如何通过Python入门机器学习 我们都知道机器学习是一门综合性极强的研究课题,对数学知识要求很高.因此,对于非学术研究专业的程序员,如果希望能入门机器学习,最好的方向还是从实践触发. 我了解到Pyt ...
- 7.boostUDP通信
客户端 #include <iostream> #include<string> #include <boost/asio.hpp> #include <st ...
- Ubuntu16.04下Mongodb官网卸载部署步骤(图文详解)(博主推荐)
不多说,直接上干货! 前期博客 Ubuntu16.04下Mongodb官网安装部署步骤(图文详解)(博主推荐) https://docs.mongodb.com/manual/tutorial/ins ...
- ActiveMQ学习笔记(13)----Destination高级特性(一)
1. Wildcards 1. Wildcards用来支持名字分层体系,它不是JMS规范的一部分,是ActiveMQ的扩展. ActiveMQ支持一下三种wildcards: 1. ".&q ...
- 马云谈AI:未来10-15年传统制造业的痛苦将远超今天的想象
马云谈AI:未来10-15年传统制造业的痛苦将远超今天的想象 “未来10到15年,传统制造业面临的痛苦将会远远超过今天的想象,企业如果不能从规模化.标准化向个性化和智慧化转型,将很难生存下去.” 9月 ...