Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save KT-Yeh/8612995 to your computer and use it in GitHub Desktop.
Save KT-Yeh/8612995 to your computer and use it in GitHub Desktop.
#include <cstdio>
using namespace std;
struct fraction{
int M; //Molecular 分子
int D; //Denominator 分母
};
int main()
{
int m,n;
while (scanf("%d%d",&m,&n))
{
if (m==1 && n==1) break;
fraction L={0,1},M={1,1},R={1,0};
while (1){
long double t1 = (long double)m/n, t2 = (long double)M.M/M.D;
if (t1 < t2){
printf("L");
R = M;
M.M += L.M;
M.D += L.D;
}
else if (t1 > t2){
printf("R");
L = M;
M.M += R.M;
M.D += R.D;
}
else{
printf("\n");
break;
}
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment