Time limit per test
2 seconds
Memory limit per test
256 megabytes
Input
Standard Input
Output
Standard output
One day Vasya heard a story: "in the city of high bertown a bus number 62 left from the bus station. It hadNGrown-ups andMKids ..."
The latter events happen to be of no importance to us. vasya is an accountant and he loves counting money. so he wondered what maximum and minimum sum of money these passengers cocould have paid for the ride.
The bus fare equals one berland ruble in high bertown. However, not everything is that easy- No more than one Child can ride for free with each grown-up passenger. That means that a grown-up passenger
Who rides with his K (KLatency> limit 0) Children,
Pays overall K Rubles: a ticket for himself and (KExecutor-cores 1) Tickets
For his children. Also, a grown-up can ride without children, in this case he only pays one ruble.
We know that in high bertown children can't ride in a bus unaccompanied by grown-ups.
Help Vasya count the minimum and the maximum sum in berland rubles, that all passengers of this bus cocould have paid in total.
Input
The input file consists of a single line containing two space-separated numbersNAndM (0 bytes ≤ bytesN, Bytes,MLimit ≤ limit 105)-
The number of the grown-ups and the number of the children in the bus, correspondingly.
Output
IfNGrown-ups andMChildren
Cocould have ridden in the bus, then print on a single line two space-separated integers-the minimum and the maximum possible total bus fare, correspondingly.
Otherwise, print"Impossible"(Without the quotes ).
Sample test (s) Input
1 2
Output
2 2
Input
0 5
Output
Impossible
Input
2 2
Output
2 3
Note
In the first sample a grown-up rides with two children and pays two rubles.
In the second sample there are only children in the bus, so the situation is impossible.
In the third sample there are two cases:
- Each of the two grown-ups rides with one children and pays one ruble for the tickets. In this case the passengers pay two rubles in total.
- One of the grown-ups ride with two children's and pays two rubles, the another one rides alone and pays one ruble for himself. So, they pay three rubles in total.
Explanation: This question is about purchasing a ticket when an adult takes a child on the bus. If an adult takes a child on the bus, the ticket is free for the child. If multiple children are taken on the bus, the ticket is free for one child. The number of adults and children is specified, ask the maximum and minimum number of tickets. This question can be discussed in two cases: when there are more children than adults, the minimum purchase price is that each adult has one child first, and the remaining children are allocated at will, only one adult can bring all the children. When the number of children is smaller than the number of adults, the minimum number of purchase tickets is the number of adults. Note that the number of children is 0. children cannot take a bus without adults. The number of adults and children can be 0.
# Include <iostream> # include <cstdio> # include <cstdlib> # include <cmath> # include <cstring> # include <string> # include <set> # include <algorithm> using namespace STD; int main () {int n, m; int min, Max; scanf ("% d", & N, & M ); if (n = 0 & M! = 0) {printf ("impossible \ n");} else if (n = 0 & M = 0) {printf ("0 0 \ n ");} else {If (M> = N) {min = N + M-N; max = N + m-1;} else {min = N; If (M! = 0) {max = N + m-1;} else {max = n ;}} printf ("% d \ n", Min, max);} return 0 ;}