Cube

Time Limit: 20 Sec  Memory Limit: 256 MB

题目连接

http://acm.uestc.edu.cn/#/problem/show/80

Description

As a student of the applied mathematics school of UESTC, WCM likes mathematics. Some day he found an interesting theorem that every positive integer's cube can be expressed as the sum of some continuous odd positive integers. For example,

11×11×11=1331=111+113+115+117+119+121+123+125+127+129+131

Facing such a perfect theorem, WCM felt very agitated. But he didn't know how to prove it. He asked his good friend Tom Riddle for help. Tom Riddle is a student of the computer science school of UESTC and is skillful at programming. He used the computer to prove the theorem's validity easily. Can you also do it?

Given a positive integer N, you should determine how to express this number as the sum of N continuous odd positive integers. You only need to output the smallest and the largest number among the N integers.

Input

The input contains an integer on the first line, which indicates the number of test cases. Each test case contains one positive integer N on a single line(0<N≤1000).

Output

For each test case, output two integers on a line, the smallest and the largest number among the N continuous odd positive integers whose sum is N×N×N.

Sample Input

2
11
3

Sample Output

111 131
7 11

HINT

题意

题解:

答案就是n(n-1)+1,n(n+1)-1

代码:

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 200000
#define mod 10007
#define eps 1e-9
int Num;
char CH[];
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline void P(int x)
{
Num=;if(!x){putchar('');puts("");return;}
while(x>)CH[++Num]=x%,x/=;
while(Num)putchar(CH[Num--]+);
puts("");
}
//************************************************************************************** int main()
{
int t=read();
while(t--)
{
int n=read();
cout<<n*(n-)+<<" "<<n*(n+)-<<endl;
}
}

cdoj 80 Cube 水题的更多相关文章

  1. HDU5053the Sum of Cube(水题)

    HDU5053the Sum of Cube(水题) 题目链接 题目大意:给你L到N的范围,要求你求这个范围内的全部整数的立方和. 解题思路:注意不要用int的数相乘赋值给longlong的数,会溢出 ...

  2. cdoj 48 Cake 水题

    Cake Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/48 Descrip ...

  3. cdoj 26 遮挡判断(shadow) 水题

    遮挡判断(shadow) Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/26 ...

  4. cdoj 24 8球胜负(eight) 水题

    8球胜负(eight) Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/24 ...

  5. HDU 5578 Friendship of Frog 水题

    Friendship of Frog Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...

  6. Codeforces Round #334 (Div. 2) A. Uncowed Forces 水题

    A. Uncowed Forces Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/pro ...

  7. Codeforces Round #115 B. Plane of Tanks: Pro 水题

    B. Plane of Tanks: Pro Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/17 ...

  8. 【BZOJ】初级水题列表——献给那些想要进军BZOJ的OIers(自用,怕荒废了最后的六月考试月,刷刷水题,水水更健康)

    BZOJ初级水题列表——献给那些想要进军BZOJ的OIers 代码长度解释一切! 注:以下代码描述均为C++ RunID User Problem Result Memory Time Code_Le ...

  9. hdu-5867 Water problem(水题)

    题目链接: Water problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Othe ...

随机推荐

  1. loadrunner11录制不成功解决方法

    问题一:loadrunner11录制时events为0的解决办法  刚安装好的11.0,系统环境是:WIN7+IE11+LR11 1.ie去掉工具—internet选项中->高级—>去掉“ ...

  2. jQuery需要掌握的技巧

    检查 jQuery 是否加载 在使用 jQuery 进行任何操作之前,你需要先确认它已经加载: if (typeof jQuery == 'undefined') { console.log('jQu ...

  3. JavaScript对象(document对象 图片轮播)

    图片轮播: 需要注意的HTML需要img标签,他和input标签一样,是非封闭的标签 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Tran ...

  4. 机器学习中的算法-决策树模型组合之随机森林与GBDT

    机器学习中的算法(1)-决策树模型组合之随机森林与GBDT 版权声明: 本文由LeftNotEasy发布于http://leftnoteasy.cnblogs.com, 本文可以被全部的转载或者部分使 ...

  5. 开扒php内核函数,第一篇 bin2hex

    这段时间真的比较有时间,所以自己用c写一下bin2hex啦 写个php的人都知道,这是个比较熟悉的函数吧,没有什么高深,只是把输入的东西以16进制输出吧了 先分析一下,这个函数要怎么写吧,他会有一定的 ...

  6. EF selection expression 与 Linq备忘

    一.左连接查询 var query = people.GroupJoin(pets, person => person, pet => pet.Owner, (person, petCol ...

  7. c++ List、Vector、Stack、Queue使用

    一.List使用 引入头文件#include <list> List基本函数Lists将元素按顺序储存在链表中. 与 向量(vectors)相比, 它允许快速的插入和删除,但是随机访问却比 ...

  8. Blog 入职新公司的一些吐槽!

    入职公司已经两个星期了,说真的也很惭愧.我们这小批入职的一共六个人,五个人是实习生,我是唯一一个社招. 所以 我要吐槽 !! 吐槽1 人家都是90后(TAT) 其实真的不要觉得年龄是压力!看看路边KF ...

  9. 记录一个 关于 python 普通方法,静态方法和类方法 的介绍。@classmethod @staticmethod

    上班时间 只贴看到最厉害的答案 回头总结 http://stackoverflow.com/questions/12179271/python-classmethod-and-staticmethod ...

  10. Java 类型信息

    <Thinking in Java 4th>第14章 类型信息 运行时类型信息(Run-Time Type Identification)使得你可以在程序运行时发现和使用类型信息. 14. ...