A. Fraction

time limit per test
1 second
memory limit per test
512 megabytes
input
standard input
output
standard output

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 ninstead 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.

Input

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

Output

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

Examples
input
3
output
1 2
input
4
output
1 3
input
12
output
5 7

解题说明:此题是一道数学题,因为a+b==n,但是a!=b所以a/b想最大,只能a和b越接近越好,所以从那个值开始出发,a–,b++直到gcd(a,b)==1说明他们是不可约分数就输出。


// codeforece.cpp: 定义控制台应用程序的入口点。
//

#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
using namespace std;

int main()
{
	int n;
	while (scanf("%d", &n) == 1)
	{
		if (n % 2 == 0)
		{
			if ((n / 2) % 2 == 0)
			{
				printf("%d %d\n", n / 2 - 1, n / 2 + 1);
			}
			else
			{
				printf("%d %d\n", n / 2 - 2, n / 2 + 2);
			}
		}
		else
		{
			printf("%d %d\n", n / 2, n / 2 + 1);
		}
	}
	return 0;
}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值