Hi,
I've tried with yours inputs and everything looks good for me !
I found exactly the same output.
Thinking that the problem could be the back space in the last line, i've changed a little my program.
But the judge says always 'Wrong Answer'.
Here is my code :
Code: Select all
#ifndef ONLINE_JUDGE
#include <fstream.h>
#endif
#include <iostream.h>
void SternBrocot(int x1,int y1)
{
int a=0,b=1,c=1,d=0;
int x=1,y=1;
if (x1==0)
{
cout << "L";
return ;
}
while ((x != x1) && (y != y1))
{
if (x1*y<y1*x)
{
cout <<"L";
c=x;
d=y;
x+=a;
y+=b;
}
else
{
cout <<"R";
a=x;
b=y;
x+=c;
y+=d;
}
}
}
int main()
{
int x1,y1;
int NewLine=0;
#ifndef ONLINE_JUDGE
ifstream cin("file.in");
#endif
while (cin >> x1 >> y1)
{
if (!((x1 ==1) && (y1==1)))
{
if (NewLine==1)
cout << endl;
SternBrocot (x1,y1);
NewLine=1;
}
}
return 0;
}
Where does my error come from ?