PDP-26 (2014) - Camp common - 1 (tvmatch)

View as PDF

Submit solution

Points: 30 (partial)
Time limit: 1.0s
Memory limit: 64M

Author:
Problem types
Allowed languages
C, C++, Java, Pascal, Python

TVMATCH

A television channel has acquired the broadcasting rights for the football championship matches. Since they paid a lot of money, the organizing authority allows the channel to determine the format of the championship that will maximize viewership.

After considerable thought, the channel executives settle on the following championship format. The championship starts with T teams and consists of R rounds. In each round, each team plays once against all other teams, and at the end of the round, the team with the lowest score is eliminated from the championship. After the end of R rounds, the champion is the team leading in the overall standings.

The channel plans to broadcast all championship matches. They want the number of matches to be M, but they have not specified the desired values of T and R.

Given M, find the values of T and R so that the total number of matches is equal to M. If this is not possible for any combination of T and R, your program should output the word "IMPOSSIBLE". If it is possible for multiple combinations of T and R, prefer the one with the highest value of R.

Input

The input consists of a single line containing only one natural number, M.

Output

The output must consist of a single line containing either the word "IMPOSSIBLE" or a pair of natural numbers T and R, separated by a single space.

Constraints

1 \le M \le 1.000.000.000
Execution time limit: 1 sec.
Memory limit: 64 MB

Examples of Input - Output
1st

STDIN (tvmatch.in)

64

STDOUT (tvmatch.out)

8 3

Explanation of the first Example: If 8 teams start, in the first round there will be 28 matches. In the second round, there will be 7 teams left, and they will play 21 matches. Finally, in the third round, there will be 6 teams left, and they will play 15 matches. The total number of matches is 28 + 21 + 15 = 64. Note that the same total number of matches can be obtained if 9 teams start and play two rounds (36 + 28 = 64).


2nd

STDIN (tvmatch.in)

371

STDOUT (tvmatch.out)

14 6

3d

STDIN (tvmatch.in)

17

STDOUT (tvmatch.out)

IMPOSSIBLE

Comments

There are no comments at the moment.