水题

One day Vasya heard a story: "In the city of High Bertown a bus number 62 left from the bus station. It had n grown-ups and m kids..."

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 could 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 (k > 0) children, pays overall k rubles: a ticket for himself and (k - 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 could have paid in total.

Input

The input file consists of a single line containing two space-separated numbers n and m (0 ≤ n, m ≤ 105) — the number of the grown-ups and the number of the children in the bus, correspondingly.

Output

If n grown-ups and m children could 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).

Example
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.
  • 题解:此题是关于一个大人带小孩坐公交买票的问题,一个大人带一个小孩时小孩免票,带多个小孩只能免去一个小孩的票,给定大人和小孩的个数,问最多和最少买票的数目是多少。此题可以分两种情况讨论,小孩数目比大人多时,最少买票的情况是每个大人先都带一个小孩,然后其余的小孩任意分配,最多就是只有一个大人带所有的小孩;当小孩数目比大人少时,最少买票的情况就是大人的个数,最多还是一个大人带所有的小孩。另外注意数目为0问题,小孩不能在没有大人的情况下坐车,大人小孩的数目都可能为0.

#include<stdio.h>
int main()
{
    int a,b;
    int max,min;
    scanf("%d %d",&a,&b);
    if(a>=b)
    {
        min=a;
        if (b==0) max=a;
        else max=a+b-1;
    }
    else
    {
        max=a+b-1;
        min=b;
    }
    if(a==0&&b!=0)
    {
        printf("Impossible\n");
    }
    else printf("%d %d",min,max);
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值