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
~~
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.
follow.
Each line will contain an integer N (0 <= N <=
2100000).
line.
All answer in the range of signed 64-bits integer.
#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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- [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 ...
- 【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 ...
- 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 ...
- 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 ...
- 【leetcode】Combination Sum II
Combination Sum II Given a collection of candidate numbers (C) and a target number (T), find all uni ...
- [LeetCode] #167# Two Sum II : 数组/二分查找/双指针
一. 题目 1. Two Sum II Given an array of integers that is already sorted in ascending order, find two n ...
随机推荐
- Grails连接外部数据库注意事项Could not determine Hibernate dialect for database name [Oracle]!
初次使用Grails时,使用其内置数据库,一直不会出错,但迁移到外部数据库时会出错Could not determine Hibernate dialect for database name [Or ...
- Interface和Abstract class区别
在面向对象中,Interface和Abstract class是实现抽象类定义的两种机制. 1.声明方法的存在而不去实现它的类被叫做抽象类(abstract class),它用于要创建一个体现某些基本 ...
- Codeforces Round #361 div2
ProblemA(Codeforces Round 689A): 题意: 给一个手势, 问这个手势是否是唯一. 思路: 暴力, 模拟将这个手势上下左右移动一次看是否还在键盘上即可. 代码: #incl ...
- 用easyui动态创建一个对话框
function randomString(len) { len = len || 32; var $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxy ...
- 几个不常见但非常出色的 .NET 开源库
NLog NLog 目前最为出色的 .NET 日志库,非常容易配置,且极具灵活性.最重要的是与 log4net 相比,NLog 的开发很活跃.顺带提一句,NLog 完全兼容 Mono. Mono.Ce ...
- Classifying plankton with deep neural networks
Classifying plankton with deep neural networks The National Data Science Bowl, a data science compet ...
- ANDROID_MARS学习笔记_S01原始版_008_Handler(异步消息处理机制)
一.流程 1.点击按钮,则代码会使handler把updateThread压到队列里去,从而执行updateThread的run() 2.run()里会通过msg.arg1 = i 和bundle来写 ...
- hadoop 序列化源码浅析
1.Writable接口 Hadoop 并没有使用 JAVA 的序列化,而是引入了自己实的序列化系统, package org.apache.hadoop.io 这个包中定义了大量的可 ...
- jquery图片轮播插件slideBox
效果预览: 源代码下载: jQuery图片轮播(焦点图)插件jquery.slideBox 特点:兼容IE6+,Chrome,Firefox,Opera,safari,可左右,可上下,可快可慢,可指定 ...
- dtree的使用
第一步:到官网下载下载dtree的相关包. 第二步:导入相关包 <link rel="StyleSheet" href="${ctx}/dtree/dtree. ...