CodeForces - 581A Vasya the Hipster (水)
来源:互联网 发布:苏州网络耗材批发 编辑:程序博客网 时间:2024/05/29 05:00
Description
One day Vasya the Hipster decided to count how many socks he had. It turned out that he had a red socks and b blue socks.
According to the latest fashion, hipsters should wear the socks of different colors: a red one on the left foot, a blue one on the right foot.
Every day Vasya puts on new socks in the morning and throws them away before going to bed as he doesn't want to wash them.
Vasya wonders, what is the maximum number of days when he can dress fashionable and wear different socks, and after that, for how many days he can then wear the same socks until he either runs out of socks or cannot make a single pair from the socks he's got.
Can you help him?
Input
The single line of the input contains two positive integers a and b (1 ≤ a, b ≤ 100) — the number of red and blue socks that Vasya's got.
Output
Print two space-separated integers — the maximum number of days when Vasya can wear different socks and the number of days when he can wear the same socks until he either runs out of socks or cannot make a single pair from the socks he's got.
Keep in mind that at the end of the day Vasya throws away the socks that he's been wearing on that day.
Sample Input
3 1
1 1
2 3
2 0
7 3
3 2
Hint
In the first sample Vasya can first put on one pair of different socks, after that he has two red socks left to wear on the second day.
Source
#include<cstdio>#include<cmath>#include<cstring>#include<algorithm>using namespace std;int main(){int n,m;while(scanf("%d%d",&n,&m)!=EOF){int k=min(n,m);int kk=(max(n,m)-k)/2;printf("%d %d\n",k,kk);}return 0;}
- CodeForces - 581A Vasya the Hipster (水)
- CodeForces 581A Vasya the Hipster
- Code Forces 581 A. Vasya the Hipster(水~)
- codeforces——581A——Vasya the Hipster
- Codeforces Round #322 A Vasya the Hipster
- Codeforces Vasya the Hipster
- A. Vasya the Hipster
- CodeForces 581A Vasya the Hipster(简单题)——Codeforces Beta Round #322 (Div. 2)
- Codeforces Round #322 (Div. 2)A. Vasya the Hipster
- Vasya the Hipster
- Codeforces 493A. Vasya and Football 水
- Codeforces 493A Vasya and Football(水)
- Codeforces A. Vasya and Socks
- Codeforces #262 (Div. 2) A. Vasya and Socks(水题)
- CodeForces 354A - Vasya and Robot (简单思维)
- A. Vasya and the Bus
- A. Vasya and the Bus
- [Codeforces] 355A - Vasya and Digital Root
- AVL树的实现
- 字符串复制中的while条件
- svn revert
- lightoj1045 - Digits of Factorial
- knn算法python实现
- CodeForces - 581A Vasya the Hipster (水)
- java并发编程(4)--线程池设计及注意问题
- RADIUS协议
- SWT概述
- 1.latch之latch redo allocation
- 第四课 初识系统调用
- android开发之提高应用启动速度_splash页面瞬间响应_避免APP启动闪白屏
- 2.latch之oracle latch
- 如何模拟cursor pin S