HDU1977 Consecutive sum II【水题】

Consecutive sum II

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

Total Submission(s): 2237    Accepted Submission(s): 1093

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

Author

Wiskey

题目大意:递推,输入N,输出为N*N*N (N+1)*(N+1)*(N+1)

#include<iostream>
using namespace std;

int main()
{
    __int64 a;
    int T;
    cin >> T;
    while(T--)
    {
        cin >> a;
        cout << a*a*a << " " <<(a+1)*(a+1)*(a+1) << endl;
    }

    return 0;
}
时间: 2024-12-29 06:55:54

HDU1977 Consecutive sum II【水题】的相关文章

hdoj 1977 Consecutive sum II

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 + 12+3+4    =

HDU 1977 Consecutive sum II(数学)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1977 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 w

POJ 2739 Sum of Consecutive Prime Numbers(水题)

Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20560   Accepted: 11243 Description Some positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representatio

LightOJ 1245 Harmonic Number (II) 水题

分析:一段区间的整数除法得到的结果肯定是相等的,然后找就行了,每次是循环一段区间,暴力 #include <cstdio> #include <iostream> #include <ctime> #include <vector> #include <cmath> #include <map> #include <queue> #include <algorithm> #include <cstring

H. 硬币水题II

H. 硬币水题II Time Limit: 1000ms Case Time Limit: 1000ms Memory Limit: 65536KB 64-bit integer IO format: %lld      Java class name: Main Submit Status PID: 29064 Font Size:  +   - 小胖有一个正反面不对称的硬币.如果抛一次这个硬币,它的正面朝上的概率为p,反面朝上的概率为1-p.现在,小胖想用这个硬币来产生等概率的决策(50%对

BNU29064——硬币水题II——————【事件概率】

硬币水题II Time Limit: 1000ms Memory Limit: 65536KB 64-bit integer IO format: %lld      Java class name: Main Submit Status PID: 29064 小胖有一个正反面不对称的硬币.如果抛一次这个硬币,它的正面朝上的概率为p,反面朝上的概率为1-p.现在,小胖想用这个硬币来产生等概率的决策(50%对50%).当然,只抛一次是不行的.小胖的策略是这样的:每一次决策,需要抛硬币两次,如果都是

leetcode 刷题之路 66 Path Sum II

Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example: Given the below binary tree and sum = 22, 5 / 4 8 / / 11 13 4 / \ / 7 2 5 1 return [ [5,4,11,2], [5,8,4,5] ] 给定一个二叉树和数字sum,输出二叉树中从根节点到

乘风破浪:LeetCode真题_040_Combination Sum II

乘风破浪:LeetCode真题_040_Combination Sum II 一.前言 这次和上次的区别是元素不能重复使用了,这也简单,每一次去掉使用过的元素即可. 二.Combination Sum II 2.1 问题 2.2 分析与解决 通过分析我们可以知道使用递归就可以解决问题,并且这次我们从头遍历一次就不会出现多次使用某一个元素了. class Solution { List<List<Integer>> ans; public List<List<Intege

leetcode_113题——Path Sum II(深度优先搜索)

Path Sum II Total Accepted: 41402 Total Submissions: 155034My Submissions Question Solution Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example:Given the below binary tree and sum = 22, 5