Two Slicers
Time limit2sMemory limit512 MB
Two slicers cut a unit circular cake into a and b equal sectors; rotate one relative to the other to minimize the gap between the largest and smallest of the a+b pieces, and print that gap as an irreducible fraction.
- Level
Medium6 of 10
- Topics
- Math, Number theory, Implementation, Brute force
- Solved
- No attempts yet
Problem
Petya and his friends want to celebrate his birthday party. Petya has a round cake for the occasion. The only thing left is to divide it, and they will have tea.
To divide the cake, Petya is going to use slicers. Each slicer has a few blades: a -slicer is a device that makes straight cuts from the center of the cake to its boundary, and thus divides the round cake into identical sectors.
Petya has a red -slicer and a blue -slicer. Fortunately, there are exactly friends at the party including Petya. So he decided to use each slicer once, so that the cake will be divided into exactly sectors.
After using the two slicers, the resulting sectors may have different sizes. Nevertheless, the cake should be divided as fairly as possible: the difference between the largest sector and the smallest sector should be the minimum possible.
Find the minimum possible difference that Petya can achieve. Find the difference between the areas of the largest and the smallest sectors after the optimal division. Regard the area of the whole cake as . Print the resulting area difference as an irreducible fraction.
Input
The first line of input contains two space-separated integers and : the parameters of the red and blue slicers ().
Output
Print an irreducible fraction in the form $a$ / $b$: the difference between the areas of the largest and the smallest of the resulting sectors after the slicers are applied optimally.
Hint
The result of optimal use of the slicers is shown below the examples. The cuts made by the red -slicer are shown as pale red thick lines. The cuts made by the blue -slicer are shown as blue thin dotted lines.