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. Xcode常见错误以及解决方案

    一.Undefined symbols for architecture x86_64: Xcode升级到5.1 新特性之一就是默认让所有App都通过64位编译器编译.原来在Xcode5.0.x的时候 ...

  2. Android 绘制计时器

    用小米的手机,发现其实还可以,无意间点开小米的计时器,发现界面非常好看和实用.于是自己仿照着写一个,由于技术不好,代码整体结构上可能有点乱,但主要的实现功能和掌握知识点. Android中绘制采用ca ...

  3. C++ new operator, delete operator, operator new, operator delete, new placement

    http://www.younfor.com/cpp-new-placement-new-operator-new.html http://www.cnblogs.com/luxiaoxun/arch ...

  4. listview加载性能优化

    在android开发中Listview是一个很重要的组件,它以列表的形式根据数据的长自适应展示具体内容,用户可以自由的定义listview每一列的布局,但当listview有大量的数据需要加载的时候, ...

  5. responsive design

    http://www.chinaz.com/manage/2011/1121/221607.shtml http://alistapart.com/article/responsive-web-des ...

  6. 如何用 Retrofit 2 在安卓上实现 HTTP 访问?

    最近,笔者对安卓开发的兴趣愈发浓厚,而且不断尝试了许多传闻很棒的开发库 -- 大部分也真的很不错.于是打算写一个系列文章,介绍使用这些让人惊叹的库建立安卓示例应用的实践.这样,读者可以自行判断,这些库 ...

  7. [codility]tree_height

    http://codility.com/demo/take-sample-test/treeheight 非常非常简单的求树的深度.不忍直视. // you can also use includes ...

  8. Spring 3.x企业应用开发实战(14)----事务

    Spring虽然提供了灵活方便的事务管理功能,但这些功能都是基于底层数据库本身的事务处理机制工作的.要深入了解Spring的事务管理和配置,有必要先对数据库事务的基础知识进行学习. 何为数据库事务 “ ...

  9. make menuconfig出错

    make[1]: *** [scripts/kconfig/mconf] Error 1 make: *** [menuconfig] Error 2 fixed: sudo apt-get inst ...

  10. 《疯狂VirtualBox实战讲学录》

    <疯狂VirtualBox实战讲学录:小耗子之VirtualBox修炼全程重现>是市面上第一部同时也是唯一一部完整介绍VirtualBox的“中文版全程实战手册”!本书完整记录了Virtu ...