SHARE
TWEET

Untitled

a guest Oct 21st, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int cmmdc(int a,int b)
  6. {
  7.     int r=0;
  8.     while(b)
  9.     {
  10.         r = a % b;
  11.         a = b;
  12.         b = r;
  13.     }
  14.     return a;
  15. }
  16.  
  17. int main()
  18. {
  19.     int a, b, p = 2;
  20.     cin >> a >> b;
  21.     while(a)
  22.     {
  23.         while(1.0/p > 1.0*a/b)
  24.             p++;
  25.         cout << p << " ";
  26.         a  = a * p - b;
  27.         if(a)
  28.         {
  29.             b = b * p;
  30.             int d = cmmdc(a,b);
  31.             a = a/d;
  32.             b = b/d;
  33.         }
  34.     }
  35.  
  36.     return 0;
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top