Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define ull unsigned long long
- using namespace std;
- ull gcd(ull a, ull b){
- if (b == 0) return a;
- else return gcd(b, a % b);
- }
- ull t, w, b;
- int main()
- {
- cin >> t >> w >> b;
- ull lcm = (w*b) / gcd(w,b);
- ull ans = (t/lcm) * (min(w,b));
- if(w!=b) ans+=min(min(w,b)-1, t);
- ull G = gcd(ans,t);
- cout << (ans/G) << '/' << (t/G) << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement