WA--------why?

General topic about Valladolid Online Judge

Moderator: Board moderators

Post Reply
famousun
New poster
Posts: 6
Joined: Sun Sep 29, 2002 5:04 pm

WA--------why?

Post by famousun »

#include<iostream.h>
#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);
idl += (int)pow(i,j-1);
}

return (i) ;
}
void main()
{
unsigned int height, sum2, fi;
cin>>height>>sum2 ;
int later ;
do{
l 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 ;

}while((sum2 == 0)&&(height == 0));
}
Let's do things better
Post Reply

Return to “General”