去年长春最简单一题 二分啊 错了好多遍 有个大坑 是个圆心处的1 可选可不选
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<cmath>
using namespace std;
#define LL __int64
LL s;
int main()
{
int i,j;
while(scanf("%I64d",&s)!=EOF)
{
LL maxz = s-,m1 = ,m2 = s-;
for(i = ; i <= ; i++)
{
LL low = ,high = s,m;
double ty = ,ts=;
while(low<=high)
{
m = (low+high)/;
ts = ,ty=;
for(j = ; j <= i ; j++)
{
ts+=ty;
ty*=m;
if(ts>s) break;
}
if(ts>s)
high = m-;
else if(ts<s)
low = m+;
else break;
}
if(s==ts&&maxz>i*m)
{
maxz = i*m;
m1 = i;
m2 = m;
}
low = ,high = s,ts=,ty=;
while(low<=high)
{
m = (low+high)/;
ts = ,ty=m;
for(j = ; j <= i ; j++)
{
ts+=ty;
ty*=m;
if(ts>s) break;
}
if(ts>s)
high = m-;
else if(ts<s)
low = m+;
else break;
}
if(s==ts&&maxz>i*m)
{
maxz = i*m;
m1 = i;
m2 = m;
}
}
printf("%I64d %I64d\n",m1,m2);
}
return ;
}