标签:des style blog color os io java ar strong
18 111 1111
1 17 2 10 3 10# include<iostream> # include<cstdio> # include<cstring> # include<algorithm> # include<cmath> # define lh __int64 using namespace std; lh powll(lh x,int y) { lh res=1; for(int i=0;i<y;i++) { res*=x; } return res; } int main() { lh n; lh r,k; while(~scanf("%I64d",&n)) { r=1; k=n-1; lh ll,rr,mm; for(int i=2;i<=45;i++) { ll=2; rr=(lh)pow(n,1.0/i); //规定上界 while(ll<=rr) { mm=(lh)(ll+rr)/2; lh ans=(mm-powll(mm,i+1))/(1-mm); if(ans==n||ans==n-1) { if(i*mm<r*k) { r=i; k=mm; } break; } else if(ans>n) rr=mm-1; else ll=mm+1; } } printf("%I64d %I64d\n",r,k); } return 0; }
标签:des style blog color os io java ar strong
原文地址:http://blog.csdn.net/u013514722/article/details/39118339