2015
05-23

# History repeat itself

Tom took the Discrete Mathematics course in the 2011,but his bad attendance angered Professor Lee who is in charge of the course. Therefore, Professor Lee decided to let Tom face a hard probability problem, and announced that if he fail to slove the problem there would be no way for Tom to pass the final exam.
As a result , Tom passed.
History repeat itself. You, the bad boy, also angered the Professor Lee when September Ends. You have to faced the problem too.
The problem comes that You must find the N-th positive non-square number M and printed it. And that’s for normal bad student, such as Tom. But the real bad student has to calculate the formula below.

So, that you can really understand WHAT A BAD STUDENT YOU ARE!!

There is a number (T)in the first line , tell you the number of test cases below. For the next T lines, there is just one number on the each line which tell you the N of the case.
To simplified the problem , The N will be within 231 and more then 0.

There is a number (T)in the first line , tell you the number of test cases below. For the next T lines, there is just one number on the each line which tell you the N of the case.
To simplified the problem , The N will be within 231 and more then 0.

4
1
3
6
10

2 2
5 7
8 13
13 28

#include<iostream>
#include<cstdio>
#include<math.h>
using namespace std;
int main()
{
int T;
__int64 n;
scanf("%d",&T);
while(T--)
{
scanf("%I64d",&n);
__int64 m=(2*n+1+sqrt(4*n+1.0))/2;
if(  (__int64(sqrt(m*1.0)))*(__int64(sqrt(m*1.0)))  ==m)
m--;
__int64 ans=0;
__int64 temp=(__int64)sqrt(m*1.0);
for(__int64 i=1;i<temp;i++)  //i也要用__int64,不然一直WA
{
ans+=i*((i+1)*(i+1)-i*i);
}
for(__int64 i=temp*temp;i<=m;i++)
ans+=temp;
printf("%I64d %I64d\n",m,ans);
}
//system("pause");
return 0;
}