CF854A.Fraction

入门

通过率:0%

时间限制:1.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

佩佳非常喜爱数学,尤其是与分数相关的部分。最近他了解到:若一个分数 的分子小于分母(即 a<ba < b),则称其为真分数;若该分数的分子与分母互质(即它们除 1 外没有其他正公因数),则称其为既约分数。

在空闲时间里,佩佳常常思考真既约分数,并用计算器将其化为小数形式。某天,他误将除号键(÷)按成了加号键(+),结果得到的是分子与分母之和,其值等于 nn,而非预期的小数形式。

佩佳想还原出原来的分数,但很快意识到这样的还原可能并不唯一。因此,他决定找出所有满足“分子与分母之和等于 nn”的真既约分数 中,值最大的那个。请帮助佩佳解决这一问题。

输入格式

In the only line of input there is an integer n (3 ≤ n ≤ 1000), the sum of numerator and denominator of the fraction.

输入仅有一行,包含一个整数 nn(3 ≤ n ≤ 10003 \leq n \leq 1000),表示该分数的分子与分母之和。

输出格式

Output two space-separated positive integers a and b, numerator and denominator of the maximum possible proper irreducible fraction satisfying the given sum.

输出两个用空格分隔的正整数 aa 和 bb,即满足给定和的最大可能的真不可约分数的分子与分母。

输入输出样例

  • 输入#1

    3

    输出#1

    1 2
  • 输入#2

    4

    输出#2

    1 3
  • 输入#3

    12

    输出#3

    5 7

输入解题思路,AI测评打分。不知道怎么写?

首页