Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rat find_best(rat l, rat r)
- {
- if (l.x >= l.y)
- {
- ll d = l.x / l.y;
- rat res = find_best(rat(l.x - d * l.y, l.y), rat(r.x - d * r.y, r.y));
- res.x += res.y * d;
- return res;
- }
- if (r.x > r.y)
- return rat(1);
- rat res = find_best(rat(r.y, r.x), rat(l.y, l.x));
- return rat(res.y, res.x);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement