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. salt-minion dead but pid file exists 正确解决方法

    说明: 看了网上很多关于alt-minion dead but pid file exists 的解决方法,千篇一律的写一个shell脚本 killproc salt-minion 见链接:http: ...

  2. Java-API-Package:org.springframwork.transaction.annotation

    ylbtech-Java-API-Package:org.springframwork.transaction.annotation 1.返回顶部 1. @NonNullApi @NonNullFie ...

  3. SQL 2008提供几种数据同步方式

    SQL 2008提供几种数据同步的方式如下. 1.日志传送(Log Shipping),定时将主数据库的日志备份,恢复到目标数据库. 2.数据库镜像(Database Mirror),原理同日志传送, ...

  4. Plain text considered harmful: A cross-domain exploit

    referer:http://balpha.de/2013/02/plain-text-considered-harmful-a-cross-domain-exploit/ Data from aro ...

  5. spring 框架整合

    struts hibernate spring 先贴出框架整合需要的maven <project xmlns="http://maven.apache.org/POM/4.0.0&qu ...

  6. SharedPreferences 用法

    private void getUserInfoFromPref(){ /* * 保存到文件的方法 * * Constant.user = (User)Constant.readObjectFromF ...

  7. JavaScript 的异步和单线程

    问题 Q:下面的代码是否能满足sleep效果? var t = true; setTimeout(function(){ t = false; }, 1000); while(t){ } alert( ...

  8. 请用fontAwesome代替网页icon小图标(转)

    1. 引言 网页小图标到处可见,如果一个网页都是干巴巴的文字和图片,而没有小图标,会显得非常简陋.下面的小图标,你是不是会经常用到? 你可能说——“我们用的都是彩色的,不是黑白的”——别着急,下面会讲 ...

  9. 关于static的继承问题

    今天研究了一下被static修饰的变量和方法,在子类中继承的问题,网上也看了别人的博客,自己也动手试了一下 代码如下 //父类 package com.xujingyang.test; public ...

  10. 吐槽下linq to sql的分页功能

    在调试程序的时候发现一个非常奇怪的问题: 用使用linq分页,分页到第二页的时候,第二页里面有第一页里出现的数据,开始还以为是. linq语句写的有问题,调试半天,无解.后来发现是因为没有排序的缘故. ...