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. java中的接口中的方法

    题目如下:(多选题)请选择以下接口定义正确的方法() A:public static void main (String[] args); B:private void test(); C:publi ...

  2. WCF与WEB API区别

  3. 关于C++的一些函数的使用方法

    关于C++的一些函数的使用方法: http://www.shouce.ren/api/c/index.html

  4. android开发面试题

    找了将近两个星期的工作,面试了5家公司,罗列一下笔试或者面试时的问题,祝大家好运 1,handler机制 答:handler执行机制:1).在主线程中创建handler 2).子线程中借助主线程的ha ...

  5. Codeforce 163 A. Substring and Subsequence DP

    A. Substring and Subsequence   One day Polycarpus got hold of two non-empty strings s and t, consist ...

  6. ES transport client底层是netty实现,netty本质上是异步方式,但是netty自身可以使用sync或者await(future超时机制)来实现类似同步调用!因此,ES transport client可以同步调用也可以异步(不过底层的socket必然是异步实现)

    ES transport client底层是netty实现,netty本质上是异步方式,但是netty自身可以使用sync或者await(future超时机制)来实现类似同步调用! 因此,ES tra ...

  7. java中log日志的使用(完全版)

    Commons_logging包 Apache通用日志包 他为Log4JLogger:NoOpLog:LogKitLogger:Jdk14Logger:AvalonLogger提供了一共通用的接口进行 ...

  8. application和javaBean练习

    编写一个jsp程序,实现将用户信息保存在application对象的用户注册 package com.sp.test; public class User { private String usena ...

  9. Django(1.7 part1)

    django安装: django解压后目录下有一个setup.py文件,在命令行运行python setup.py install,当前前提是已经安装了python才能执行命令,然后用下面命令检查dj ...

  10. WPF 基础

    关于布局的规则 控件的布局应该由容器来决定,而不是通过自身使用margin之类的东西来控制位置 避免为控件定义明确的尺寸,但应该限定一个可接受的最大及最小尺寸 不要将界面元素设置成与屏幕坐标相关 容器 ...