the Sum of Cube

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 405    Accepted Submission(s): 224

Problem Description
A range is given, the begin and the end are both integers. You should sum the cube of all the integers in the range.
 
Input
The first line of the input is T(1 <= T <= 1000), which stands for the number of test cases you need to solve.

Each case of input is a pair of integer A,B(0 < A <= B <= 10000),representing the range[A,B].
 
Output
For each test case, print a line “Case #t: ”(without quotes, t means the index of the test case) at the beginning. Then output the answer – sum the cube of all the integers in the range.
 
Sample Input
2
1 3
2 5
 
Sample Output
Case #1: 36
Case #2: 224
 
Source
 

代码:

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std; int main()
{
long long a,b;
int ca=1;
int t;
scanf("%d",&t);
while(t--)
{
scanf("%I64d%I64d",&a,&b);
printf("Case #%d: %I64d\n",ca++,(b*(b+1)/2)*(b*(b+1)/2)-(a*(a-1)/2)*(a*(a-1)/2));
}
return 0;
}

hdu 5053 the Sum of Cube(上海网络赛)的更多相关文章

  1. 2014上海网络赛 HDU 5053 the Sum of Cube

    水 #include <stdio.h> #include <stdlib.h> #include<math.h> #include<iostream> ...

  2. HDU 5053 the Sum of Cube

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5053 解题报告:用来陶冶情操的题,求a到b的三次方的和. #include<stdio.h> ...

  3. HDU 5053 the Sum of Cube(简单数论)

    http://acm.hdu.edu.cn/showproblem.php?pid=5053 题目大意: 求出A^3+(A+1)^3+(A+2)^3+...+B^3和是多少 解题思路: 设f(n)=1 ...

  4. 杭电 5053 the Sum of Cube(求区间内的立方和)打表法

    Description A range is given, the begin and the end are both integers. You should sum the cube of al ...

  5. HDU 4759 Poker Shuffle(2013长春网络赛1001题)

    Poker Shuffle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  6. HDU 5875 Function -2016 ICPC 大连赛区网络赛

    题目链接 网络赛的水实在太深,这场居然没出线zzz,差了一点点,看到这道题的的时候就剩半个小时了.上面是官方的题意题解,打完了才知道暴力就可以过,暴力我们当时是想出来了的,如果稍稍再优化一下估计就过了 ...

  7. HDU 4763 Theme Section (2013长春网络赛1005,KMP)

    Theme Section Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  8. HDU 4751 Divide Groups (2013南京网络赛1004题,判断二分图)

    Divide Groups Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tot ...

  9. HDU 4745 Two Rabbits (2013杭州网络赛1008,最长回文子串)

    Two Rabbits Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Tota ...

随机推荐

  1. ruby简单的基本 3

    类 Ruby一切都是对象,它包含了一个恒定.例如,可以使用.class物业查看对象的类型,你可以看一下1.class.你会发现常1类型是Fixnum,1但它是Fixnum的一个例子. Ruby本类cl ...

  2. 查询系统--基于Solr4.9.0实现

    为什么非要搜索系统 随着在产品的数量的增长.和复杂的检索要求,直接从数据库中检索信息,它已经无法满足展示机搜索需求. 实例: keyword=%E8%8B%B9%E6%9E%9C&enc=ut ...

  3. 苦B的程序猿道路数据验证

    发生了什么 再一次苦B程序猿和苦C程序猿结对话发生编程周期 此代码: public void deleteAllExtendAclsFromContent(String contentId) thro ...

  4. SQL Server 2008性能故障排查(三)——I/O

    原文:SQL Server 2008性能故障排查(三)--I/O 接着上一章:CPU瓶颈 I/O瓶颈(I/O Bottlenecks): SQLServer的性能严重依赖I/O子系统.除非你的数据库完 ...

  5. MEF初体验之二:定义组合部件和契约

    组合部件 在MEF中,一个组合部件就是一个组合单元,组合部件"出口"其它组合部件需要的服务并且从其它部件"进口"需要的服务.在MEF编程模型中,为了声明组合部件 ...

  6. SQL Server审计功能入门:SQL Server审核 (SQL Server Audit)

    原文:SQL Server审计功能入门:SQL Server审核 (SQL Server Audit) 介绍 Audit是SQL Server 2008之后才有的功能,它能告诉你"谁什么时候 ...

  7. 三种字符编码:ASCII、Unicode和UTF-8

    原文:三种字符编码:ASCII.Unicode和UTF-8 什么是字符编码? 计算机只能处理数字,如果要处理文本,就必须先把文本转换为数字才能处理.最早的计算机在设计时采用8个比特(bit)作为一个字 ...

  8. LInq 与lambda表达式

    LInq 与lambda表达式 LinQ是我们常用的技术之一.因为我们绕不开的要对数据进行一系列的调整,如 排序. 条件筛选.求和.分组.多表联接 等等. lambda则是我们常用的语法糖,配合lin ...

  9. WebHooks

    WebHooks ASP.NET 5 Beta 7 版本   在 VS2015 发布的同时,微软也发布了 ASP.NET 5 的路线图(详见ASP.NET 5 Schedule and Roadmap ...

  10. 使用javascript实现html文字不可选

    如何使用js让html该文本是不可选定它?首先想到的是用css选择实现,如下面: -webkit-touch-callout: none; -webkit-user-select: none; -kh ...