BUPT2017 wintertraining(15) #8C
题意
题解
代码
代码语言:javascript复制#include <cstdio>
#include <cmath>
#define ll long long
int t;
const int N=1LL<<16;
ll n,x,ans,a[N];
int main(){
for(int i=1;i<=N;i )
a[i]=a[i-1] (ll)(i*2 1)*i;
scanf("%d", &t);
while(t--){
scanf("%lld", &n);
ll l=1, r=1LL<<32;
while(l<r){
ll m=l r>>1;
if(m-(ll)sqrt(m)<n)
l=m 1;
else
r=m;
}
x=l;
ll g=floor(sqrt(x));
ans=a[(int)g-1] (x-g*g 1)*g;
printf("%lld %lldn", x, ans);
}
return 0;
}