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. ASP.NET-AuthorizeAttribute做身份验证操作

    代码顺序为:OnAuthorization-->AuthorizeCore-->HandleUnauthorizedRequest 如果AuthorizeCore返回false时,才会走H ...

  2. SQL SERVER-union

    UNION 操作符用于合并两个或多个 SELECT 语句的结果集. 请注意,UNION 内部的每个 SELECT 语句必须拥有相同数量的列.列也必须拥有相似的数据类型.同时,每个 SELECT 语句中 ...

  3. HDU 4308 Contest 1

    纯BFS+优先队列扩展. #include <iostream> #include <cstdio> #include <cstring> #include < ...

  4. MySQL高可用系列之MHA(二)

    一.參数说明 MHA提供了一系列配置參数.深入理解每一个參数的详细含义,对优化配置.合理使用MHA非常重要.非常多高可用性也都是通过合理配置一些參数而实现的. MHA包含例如以下配置參数,分别说明例如 ...

  5. Java线程演示样例 - 继承Thread类和实现Runnable接口

    进程(Process)和线程(Thread)是程序执行的两个基本单元. Java并发编程很多其它的是和线程相关. 进程 进程是一个独立的执行单元,可将其视为一个程序或应用.然而,一个程序内部同事还包括 ...

  6. 一步一步跟我学习hadoop(7)----hadoop连接mysql数据库运行数据读写数据库操作

        为了方便 MapReduce 直接訪问关系型数据库(Mysql,Oracle).Hadoop提供了DBInputFormat和DBOutputFormat两个类.通过DBInputFormat ...

  7. poj2492--A Bug&#39;s Life(并查集变形)

    A Bug's Life Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 28703   Accepted: 9350 De ...

  8. 【LeetCode-面试算法经典-Java实现】【145-Binary Tree Postorder Traversal(二叉树非递归后序遍历)】

    [145-Binary Tree Postorder Traversal(二叉树非递归后序遍历)] [LeetCode-面试算法经典-Java实现][全部题目文件夹索引] 原题 Given a bin ...

  9. intellij idea 13&amp;14 插件推荐及高速上手建议 (已更新!)

    早些年 在外企的时候,公司用的是intellij idea ,当时也是从eclipse.MyEclipse转过去的非常是不习惯. 用了一周明显感觉爱上它了.由于它非常智能,并且能纠正你非常多不好的习惯 ...

  10. System.getProperty()方法可以获取的值

    /** 获得当前类的完整路径.最后一句 */ package org.outman.dms.server; import java.net.MalformedURLException; import ...