Fraction
InterviewTime limit2sMemory limit1024 MB
Given n, find the largest proper fraction whose numerator and denominator are coprime and sum to n.
- Level
Medium5 of 10
- Topics
- Number theory, Math, Implementation, Brute force
- Solved
- No attempts yet
Problem
Kolya is in third grade, and they are studying simple fractions with natural numerators and denominators. Yesterday in class Kolya learned that a fraction is called proper if its numerator is less than its denominator, and irreducible if there is no fraction equal to it with a smaller natural numerator and denominator.
Kolya loves mathematics, so at home he experimented for a long time, inventing and solving various problems with proper irreducible fractions. He suggests that you solve one of these problems with a computer.
Find the largest proper irreducible fraction whose numerator and denominator sum to .
Input
The input file contains a single integer ().
Output
Print the numerator and denominator of the required fraction to the output file.