标签:
Description
Input
Output
Sample Input
Sample Output
#include <cstdio> #include <cmath> #include <cstring> #include <ctime> #include <iostream> #include <algorithm> #include <set> #include <vector> #include <queue> #include <typeinfo> #include <map> typedef long long ll; using namespace std; #define inf 10000000 inline ll read() { ll x=0,f=1; char ch=getchar(); while(ch<‘0‘||ch>‘9‘) { if(ch==‘-‘)f=-1; ch=getchar(); } while(ch>=‘0‘&&ch<=‘9‘) { x=x*10+ch-‘0‘; ch=getchar(); } return x*f; } //*************************************************************** int main() { int t; while(scanf("%d",&t)!=EOF) { while(t--) { ll n=read(); ll tmp=(ll)sqrt(n*1.0); ll i=1; while((ll)sqrt(n+i)!=i)i++; ll x=n+i; ll flag=sqrt(n+i); ll ans=0; for(ll i=2;i<=flag;i++) { ans+=(i*i-(i-1)*(i-1))*(i-1); } ans+=(x-flag*flag+1)*flag; cout<<x<<" "<<ans<<endl; } } return 0; }
HDU 4342History repeat itself 数学
标签:
原文地址:http://www.cnblogs.com/zxhl/p/4746146.html