Vasya and the Bus
来源:互联网 发布:袜子品牌 知乎 编辑:程序博客网 时间:2024/05/20 16:41
Description
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).
Sample Input
Input
1 2
Output
2 2
Input
0 5
Output
Impossible
Input
2 2
Output
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).
Sample Input
Input
1 2
Output
2 2
Input
0 5
Output
Impossible
Input
2 2
Output
2 3
#include<stdio.h>int main(){int m,n,max,min;while(~scanf("%d%d",&n,&m)){ if(n==0){ if(m==0) {printf("0 0\n");} else{printf("Impossible\n");}continue;} else if(n<=m){max=m+n-1; min=m;} else if(m==0) {max=n;min=n;} else{max=m+n-1;min=n;} printf("%d %d\n",min,max);} return 0;}
0 0
- Vasya and the Bus
- Vasya and the Bus
- A. Vasya and the Bus
- A. Vasya and the Bus
- CF190A:Vasya and the Bus(易错题)
- Arduino and the SPI bus
- The Bus and the Subway Train
- Vasya and Digital Root
- Vasya and Public Transport
- Vasya and Robot
- C. Vasya and Robot
- A. Vasya and Socks
- A. Vasya and Socks
- CF493B Vasya and Wrestling
- A. Vasya and Football
- A Vasya and Football
- B. Vasya and Wrestling
- C. Vasya and Basketball
- arm linux下使用mdev vs udev
- linux命令解析--ss
- Vim 命令 基础 详细介绍
- 学习 Policy based design - 读C++设计新思维-泛型编程与设计模式的应用
- 关于TrueType字体
- Vasya and the Bus
- 冬天的温泉
- Java POI操作XML
- 简单介绍基于颜色的阴影检测算法
- 通用makefile是如何炼成的(IV)
- Android百度地图如何计算两点之间距离?
- 运放总结
- linux jira安装
- JSON对象