Created
January 25, 2014 07:26
-
-
Save KT-Yeh/8612995 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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