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

InputThe 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].OutputFor 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

首先要明白这一题的题意,就是求一个范围内的所有整数数的立方和

注意:数据范围要用 long long

   求立方和可以用pow函数——>pow(j, 3)

感觉第二个数据错了…………

AC代码

#include<stdio.h>

int solve(int x)
{
return x*x*x;
} int main()
{
int t;
int num = ;
scanf("%d", &t);
while(t--)
{
int a, b;
long long sum = ; scanf("%d %d", &a, &b);
for(int i = a; i <= b; i++)
{
sum += solve(i);
}
num++;
printf("Case #%d: %lld\n", num, sum);
}
return ;
}

H - the Sum of Cube(水题)的更多相关文章

  1. HDU5053the Sum of Cube(水题)

    HDU5053the Sum of Cube(水题) 题目链接 题目大意:给你L到N的范围,要求你求这个范围内的全部整数的立方和. 解题思路:注意不要用int的数相乘赋值给longlong的数,会溢出 ...

  2. Xtreme8.0 - Sum it up 水题

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

  3. cdoj 80 Cube 水题

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

  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. SPOJ 3693 Maximum Sum(水题,记录区间第一大和第二大数)

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

  8. HDU 4593 H - Robot 水题

    H - RobotTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.act ...

  9. HDU 4788 Hard Disk Drive (2013成都H,水题)

    Hard Disk Drive Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

随机推荐

  1. Android实现推送方式解决方案 - 长连接+心跳机制(MQTT协议)

    本文介绍在Android中实现推送方式的基础知识及相关解决方案.推送功能在手机开发中应用的场景是越来起来了,不说别的,就我们手机上的新闻客户端就时不j时的推送过来新的消息,很方便的阅读最新的新闻信息. ...

  2. Day3-Python基础3---函数递归和函数式方程

    一.函数的递归 在函数内部,可以调用其他函数.如果一个函数在内部调用自身本身,这个函数就是递归函数. 递归特性: 1. 必须有一个明确的结束条件 2. 每次进入更深一层递归时,问题规模相比上次递归都应 ...

  3. java继承 子类重写父类方法

    package com.addd; //多态 public class Sld { private String name = "zhangsan"; public Sld() { ...

  4. java流2

    总结:字符转换 package com.b; //流类 import java.io.*; public class uy { // 读取字符 public static void main(Stri ...

  5. Microsoft Sync Framework下的快速开发同步程序

    Microsoft Sync Frameworks简称MSF,是一个综合的同步平台,MSF支持应用程序,服务,设备的在线以及离线同步.MSF主要有以下几个部件组成:     * Sync Servic ...

  6. 12-18Windows窗体应用小程序之记事本(1)

    一.记事本制作(1) C#结合窗体制作小程序,相比较之前的控制台应用程序可能要改善了好多,最起码界面看起来可以高仿一下了,但是最重要的还是要看其里面的功能是否实现.所以,要以实现其实用功能为主.今天利 ...

  7. C#一般处理程序 ashx.cs使用Session报错问题

    HttpContext.Current.Session["UserID"].ToString();//报错,报Session为Null, 此时需要添加引用和继承IRequiresS ...

  8. 关于struts2.3的action

    struts2.3中支持实时配置,也就是说不用在struts.xml中进行配置.但是所有的action文件应该放在有路径名含action的包中,否则程序无法发现你的action. 这个问题,难为了我好 ...

  9. 使用SharedPreferences接口来实现记住密码功能

    SharedPreferences接口非常适合用来存储零散的数据.这里我们用来实现记录用户名和密码的功能.在前面我用过IO流来实现记住密码的功能.那么用SharedPreferences接口会比用IO ...

  10. sqlplus--sqlldr基础运用

    a.ctl load data                                         infile *                                     ...