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(水题)的更多相关文章

  1. cdoj 80 Cube 水题

    Cube Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/80 Descrip ...

  2. Xtreme8.0 - Sum it up 水题

    Sum it up 题目连接: https://www.hackerrank.com/contests/ieeextreme-challenges/challenges/sum-it-up Descr ...

  3. 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 ...

  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. 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 ...

  8. SPOJ 3693 Maximum Sum(水题,记录区间第一大和第二大数)

    #include <iostream> #include <stdio.h> #include <algorithm> #define lson rt<< ...

  9. ACM水题

    ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...

随机推荐

  1. nignx 502错误不能使用/的路径方式 即pathinfo

    在server中加入 include enable-php-pathinfo.conf; 引入nginx.conf下的这个文件即可. 如果是tp框架,主要隐藏index.php的入口文件,再加入下面这 ...

  2. SVN学习总结(1)——SVN简介及入门使用

    SVN简介:  为什么要使用SVN?       程序员在编写程序的过程中,每个程序员都会生成很多不同的版本,这就需要程序员有效的管理代码,在需要的时候可以迅速,准确取出相应的版本. Subversi ...

  3. angular-事件

    ng-click事件 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 <div ng-app="myApp ...

  4. C++异常注意事项

    C++里面catch对于类型转换,限制比参数传递时候要多: 不可以进行标准算术转换和类的自定义转换:在函数参数匹配的过程中,可以进行很多的类型转换.但是在异常匹配的过程中,转换的规则要严厉. 标准算术 ...

  5. [React] Understanding setState in componentDidMount to Measure Elements Without Transient UI State

    In this lesson we'll explore using setState to synchronously update in componentDidMount. This allow ...

  6. java ee5的新特性

    1.标注 一种元数据,作用分为三类:编写文档@Document.代码分析@Deparecated(过时的)和编译检查@override(重写) 2.EJB3 EJB2的升级版,商业化的java bea ...

  7. Spring25大面试题

    1.什么是Spring框架?Spring框架有哪些主要模块? Spring框架是一个为Java应用程序的开发提供了综合.广泛的基础性支持的Java平台.Spring帮助开发人员攻克了开发中基础性的问题 ...

  8. c# 获取一年中的周/根据一年中的第几周获取该周的开始日期与结束日期

    /// <summary> /// 获取一年中的周 /// </summary> /// <param name="dt">日期</par ...

  9. Binary operations #1

    https://www.codewars.com/kata/binary-operations-number-1/train/csharp Your work is to write a method ...

  10. hdoj--1260--Tickets(简单dp)

    Tickets Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Su ...