Consecutive sum II

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2523    Accepted Submission(s):
1219

Problem Description
Consecutive sum come again. Are you ready? Go
~~
1    = 0 + 1
2+3+4    = 1 + 8
5+6+7+8+9  = 8 + 27

You can
see the consecutive sum can be representing like that. The nth line will have
2*n+1 consecutive numbers on the left, the first number on the right equal with
the second number in last line, and the sum of left numbers equal with two
number’s sum on the right.
Your task is that tell me the right numbers in the
nth line.
 
Input
The first integer is T, and T lines will
follow.
Each line will contain an integer N (0 <= N <=
2100000).
 
Output
For each case, output the right numbers in the Nth
line.
All answer in the range of signed 64-bits integer.
 
Sample Input
3
0
1
2
 
Sample Output
0 1
1 8
8 27
 
找规律
#include<stdio.h>
#include<string.h>
int main()
{
long long m,n;
scanf("%lld",&n);
while(n--)
{
scanf("%lld",&m);
printf("%lld %lld\n",m*m*m,(m+1)*(m+1)*(m+1));
}
return 0;
}

  

hdoj 1977 Consecutive sum II的更多相关文章

  1. HDOJ(HDU) 1977 Consecutive sum II(推导、、)

    Problem Description Consecutive sum come again. Are you ready? Go ~~ 1 = 0 + 1 2+3+4 = 1 + 8 5+6+7+8 ...

  2. Leetcode 笔记 113 - Path Sum II

    题目链接:Path Sum II | LeetCode OJ Given a binary tree and a sum, find all root-to-leaf paths where each ...

  3. Path Sum II

    Path Sum II Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals ...

  4. [leetcode]Path Sum II

    Path Sum II Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals ...

  5. 【leetcode】Path Sum II

    Path Sum II Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals ...

  6. 32. Path Sum && Path Sum II

    Path Sum OJ: https://oj.leetcode.com/problems/path-sum/ Given a binary tree and a sum, determine if ...

  7. LeetCode: Path Sum II 解题报告

    Path Sum II Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals ...

  8. 【leetcode】Combination Sum II

    Combination Sum II Given a collection of candidate numbers (C) and a target number (T), find all uni ...

  9. [LeetCode] #167# Two Sum II : 数组/二分查找/双指针

    一. 题目 1. Two Sum II Given an array of integers that is already sorted in ascending order, find two n ...

随机推荐

  1. iOS+JSPatch在线修改app功能-b

    什么是热更新? 举个例子,你的app上架了,但是突然想添加个小功能,那么你有两种方法 第一种方法:在原生代码中修改源代码,然后提交到appStore,这个过程真是很漫长...虽然最近我提交的都是一两天 ...

  2. The output char buffer is too small to contain the decoded characters, encoding 'Unicode (UTF-8)' fallback 'System.Text.DecoderReplacementFallback'.

    Exception when executing ) br is a binary reader. The data to peak is D000 (D0=208) The cause is, fo ...

  3. visualvm 监控 远程 机器上的 Java 程序

    JDK里面本身就带了很多的监控工具,如JConsole等. 我们今天要讲的这款工具visualvm,就是其中的一款.但是这款工具是在JDK1.6.07及以上才有的.它能够对JAVA程序的JVM堆.线程 ...

  4. Struts2WebUtil

    一个简单的实用工具类 package cn.jorcen.commons.util; import javax.servlet.http.HttpServletRequest; import org. ...

  5. 带节假日JS万年历控件代码

    <form name="CLD" class="content"> <table width="100%" border= ...

  6. 原生javascript效果:无缝滚动

    <style type="text/css"> #con {width:400px; padding:10px; margin:20px auto; text-alig ...

  7. Burp Suite Walkthrough(中文版)

    Burp Suite是Web应用程序测试的最佳工具之一,其多种功能可以帮我们执行各种任务.请求的拦截和修改,扫描web应用程序漏洞,以暴力破解登陆表单,执行会话令牌等多种的随机性检查.本文将做一个Bu ...

  8. flash 类和对象的关系

    每个具体的对象后面都隐藏着抽象的类. flash 中as3.0中所有的类,都是为了创建对象所用的.反过来,所创建的任何具体对象都隐藏着抽象的类. 类可以把它看做函数,类的属性是函数的数据,类的方法是函 ...

  9. UVA 658 It's not a Bug, it's a Feature!

    这个题目巧妙之处在于用二进制的每个位1,0分别表示bug的有无,以及实施补丁对相应bug的要求以及实施后的对bug的影响. 软件bug的状态:1表示相应bug仍然存在,0表示已经修复.这样可以将软件的 ...

  10. SQL跨表更新

    [一篮饭特稀原创,转载请注明出自http://www.cnblogs.com/wanghafan/p/4384039.html]  前提:两张表要更新的字段.关联字段结构一致 更新库:FJPDI_TZ ...