#P8012. [COCI 2013/2014 #4] NASLJEDSTVO

[COCI 2013/2014 #4] NASLJEDSTVO

Problem Description

There is a pile of coins. Someone splits this pile into NN parts as evenly as possible and takes one part away, leaving OO coins.

By “splitting into NN parts as evenly as possible”, we mean dividing the coins into NN piles, where each pile contains an integer number of coins, and the difference in the number of coins between any two piles is at most 11.

We assume that the part taken by this person is one of the smaller parts.

Please find the minimum and the maximum possible number of coins in the original pile.

Input Format

The first line contains a positive integer NN, meaning the pile is split into NN equal parts.

The second line contains a positive integer OO, meaning that after taking 11 part out of the NN parts, there are OO coins left.

Output Format

Output one line with two positive integers, representing the minimum and the maximum possible number of coins in the original pile.

2
5
9 10
3
5
7 7

Hint

Sample Explanation #1

The original pile could have had 99 coins. The person could have split it into 4+54+5 and taken 44.

The original pile could have had 1010 coins. The person could have split it into 5+55+5 and taken 55.

Constraints

For 100%100\% of the testdata, 2N152\le N\le 15, NO100N\le O\le 100.

Source

The score of this problem follows the original COCI problem setting, with a full score of 5050.

Translated from COCI2013-2014 CONTEST #4 T1 NASLJEDSTVO

Translated by ChatGPT 5