Advertisement
juaniisuar

Untitled

Oct 31st, 2015
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #include <iostream>
  2. #define ull unsigned long long
  3.  
  4. using namespace std;
  5.  
  6. ull gcd(ull a, ull b){
  7. if (b == 0) return a;
  8. else return gcd(b, a % b);
  9. }
  10.  
  11. ull t, w, b;
  12.  
  13. int main()
  14. {
  15. cin >> t >> w >> b;
  16. ull lcm = (w*b) / gcd(w,b);
  17. ull ans = (t/lcm) * (min(w,b));
  18.  
  19. if(w!=b) ans+=min(min(w,b)-1, t);
  20.  
  21. ull G = gcd(ans,t);
  22. cout << (ans/G) << '/' << (t/G) << endl;
  23.  
  24. return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement