hdu4342 History repeat itself-------多校联合五

水题就不多说什么了。
#include<iostream>#include<cstdlib>#include<stdio.h>#define ll __int64using namespace std;int main(){    int t;    ll n;    scanf("%d",&t);    while(t--)    {        scanf("%I64d",&n);        if(n==1)        {            printf("2 2\n");            continue;        }        ll cc=0;        ll i;        for(i=1;;i++)        {            ll res=i*i-cc;            if(res>n) break;            cc++;        }        ll kk=n+cc;        ll j,k;        ll ans=1;ll oo=1;        for(j=1,k=2;j<cc;j++)        {            ans+=(k*k-(k-1)*(k-1))*oo+1;            oo++;k++;        }        k--;        if(kk>k*k)        ans+=(kk-k*k)*oo;        printf("%I64d %I64d\n",kk,ans);    }}

你可能感兴趣的:(数论)