CF190A.Vasya and the Bus

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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.

一天,瓦西娅听到了这样一个故事:“在高伯特城,一辆编号为62的公交车从汽车站出发。车上共有 nn 名成年人和 mm 名儿童……”

之后发生的事件对我们而言并不重要。瓦西娅是一名会计,他酷爱数钱。因此,他开始思考:这些乘客乘车总共可能支付的最大与最小金额分别是多少?

在高伯特城,公交车票价为每人次1伯兰德卢布。但事情并非如此简单——每名成年人最多可携带一名儿童免费乘车。也就是说,若一名成年人携 kk(k>0k > 0)名儿童乘车,则他需总共支付 kk 卢布:其中1卢布为自己购票,其余 k−1k-1 卢布为所带儿童中除1名免费者外的其余儿童购票。此外,成年人也可独自乘车,此时仅需支付1卢布。

我们还知道,在高伯特城,儿童不得在无成年人陪同的情况下单独乘坐公交车。

请帮助瓦西娅计算:该公交车上所有乘客总共可能支付的最小与最大金额(单位:伯兰德卢布)。

输入格式

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.

输入文件仅包含一行,其中有两个以空格分隔的数字 nn 和 mm(0 ≤ n, m ≤ 1050 \le n, m \le 10^5),分别表示公交车上成年人和儿童的数量。

输出格式

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).

如果 n 名成年人和 m 名儿童可以乘坐该公交车,则在一行中输出两个以空格分隔的整数——分别表示可能的最低与最高总车费。

否则,输出 "Impossible"(不带引号)。

输入输出样例

  • 输入#1

    1 2

    输出#1

    2 2
  • 输入#2

    0 5

    输出#2

    Impossible
  • 输入#3

    2 2

    输出#3

    2 3

说明/提示

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.

在第一个样例中,一名成年人与两名儿童同乘,支付两卢布。

在第二个样例中,公交车上仅有儿童,因此该情况不可能发生。

在第三个样例中,存在两种情形:

  • 两名成年人各自带一名儿童乘车,每人支付一卢布车票费用。此时乘客共支付两卢布。
  • 其中一名成年人带两名儿童乘车并支付两卢布,另一名成年人单独乘车并为自己支付一卢布。因此,他们共支付三卢布。

输入解题思路,AI测评打分。不知道怎么写?

首页