fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4. #include <vector>
  5. #include <bitset>
  6. #include <stdio.h>
  7. #include <math.h>
  8. using namespace std;
  9. typedef std::vector<int> vi;
  10. typedef std::vector<pair<int, int> > vii;
  11. #define FOR(l) for(vi::iterator it=l.begin();it!=l.end();it++)
  12. #define FOR_L(l, s, e) for(vi::iterator it=l.begin()+s;it!=l.end()-e;it++)
  13.  
  14. //----------Main source code -----------------//
  15. int main() {
  16. int m,n;
  17. double num;
  18. while(scanf("%d %d", &m, &n)!=EOF&&(m!=1||n!=1)){
  19. num=(double)m/n;
  20. string o="";
  21. double mid=1;
  22. int fn, fd, ln, ld, mn=1, md=1;
  23. fn=0;fd=1;ln=1;ld=0;
  24. while(!(m==mn&&n==md)){
  25. mn=fn+ln;
  26. md=ld+fd;
  27. mid=(double)mn/md;
  28. if(num>mid) fn=mn, fd=md, o+="R";
  29. else if(num<mid) ln=mn, ld=md, o+="L";
  30. }
  31. cout<<o<<endl;
  32. }
  33. return 0;
  34.  
  35. }
Success #stdin #stdout 0s 3476KB
stdin
5 7
878 323
1 1
stdout
LRRLR
RRLRRLRLLLLRLRRRL