#include<math.h>
unsigned int idl , tot;
int js(int later,int sume,int height)
{
int temp , i ,j;
for(i = 2 ; i<=later ; i++)
{
temp = (int)(log(sume)/log(i) );
if((int)pow(i+1,temp) == height)
break ;
}
for(j=1; j <= temp ; j++)
{
tot += ((int)pow(i,j)*(int)pow(i+1,temp-j));

}
return (i) ;
}
void main()
{
unsigned int height, sum2, fi;
cin>>height>>sum2 ;
int later ;
while((sum2 != 0)&&(height != 0))
{
later = (int)sqrt(sum2) ;
if(sum2 == 1)
{
idl = 0 ;
tot = height ;
}
else if(height - sum2 == 1)
{
idl = 1 ;
tot = height + sum2 ;
}
else
{
idl = 0; tot = height;
fi = js(later,sum2,height) ;
}
cout<<idl<<' '<<tot<<endl ;
cin>>height>>sum2 ;
}
}
I have read someone's code and got some idea ,but It got WA
i 'm confused ,tell me why?
Thanks !