CF 854A - Fraction
Petya is a big fan of mathematics, especially its part related to fractions. Recently he learned that a fraction is called proper iff its numerator is smaller than its denominator (a < b) and that the fraction is called irreducible if its numerator and its denominator are coprime (they do not have positive common divisors except 1).
During his free time, Petya thinks about proper irreducible fractions and converts them to decimals using the calculator. One day he mistakenly pressed addition button ( + ) instead of division button (÷) and got sum of numerator and denominator that was equal to n instead of the expected decimal notation.
Petya wanted to restore the original fraction, but soon he realized that it might not be done uniquely. That's why he decided to determine maximum possible proper irreducible fraction such that sum of its numerator and denominator equals n. Help Petya deal with this problem.
----------------------------------------------------
Petya 是数学的忠实粉丝,尤其是与分数相关的部分。 最近他了解到,如果一个分数的分子小于分母(a < b),则该分数被称为真分数;如果其分子和分母互质(除了 1 之外,它们没有正公约数),则该分数被称为不可约分数。
在空闲时间,佩蒂亚思考不可约分数并使用计算器将其转换为小数。 有一天,他错误地按了加法按钮( + )而不是除法按钮(÷),得到的分子和分母之和等于n,而不是预期的小数符号。
彼佳想要恢复原来的分数,但很快他意识到这可能不是唯一的方法。 这就是为什么他决定确定最大可能的真不可约分数,使其分子和分母之和等于 n。 帮助 Petya 解决这个问题。
-----------------------------------------------
依次遍历即可,主要是要判断最大公约数等于1;
下面是代码: