codeforces——581A——Vasya the Hipster
来源:互联网 发布:淘宝基金欠款 编辑:程序博客网 时间:2024/05/29 03:49
One day Vasya the Hipster decided to count how many socks he had. It turned out that he hada 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?
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.
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.
3 1
1 1
2 3
2 0
7 3
3 2
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.
先穿不同色的袜子,之后穿相同的,输出两种情况出现的次数。
水
#include <iostream>#include<cstring>#include<string>#include<stdio.h>#include<algorithm>#include<set>using namespace std;int main(){ int n,m; while(cin>>n>>m!=NULL) { if(n<m) { int t=n; n=m; m=t; } cout<<m<<' '; n-=m; cout<<n/2<<endl; } return 0;}
- codeforces——581A——Vasya the Hipster
- CodeForces 581A Vasya the Hipster(简单题)——Codeforces Beta Round #322 (Div. 2)
- CodeForces 581A Vasya the Hipster
- CodeForces - 581A Vasya the Hipster (水)
- Codeforces Round #322 A Vasya the Hipster
- Codeforces Vasya the Hipster
- A. Vasya the Hipster
- Codeforces Round #322 (Div. 2)A. Vasya the Hipster
- Code Forces 581 A. Vasya the Hipster(水~)
- Vasya the Hipster
- Codeforces A. Vasya and Socks
- Codeforces Round #319 (Div. 2) ——C. Vasya and Petya's Game(数学题)
- 【打CF,学算法——二星级】Codeforces 584C Marina and Vasya (简单构造)
- Codeforces Round #324 (Div. 2)——C. Marina and Vasya
- Codeforces Round #354 (Div. 2)——C. Vasya and String(尺取)
- A. Vasya and the Bus
- A. Vasya and the Bus
- codeforces—— 869A —— The Artful Expedient
- PackBits算法
- linux top命令中各cpu占用率含义及案例分析
- Masonry 自动布局使用案例
- React this.state
- C#之转义符
- codeforces——581A——Vasya the Hipster
- 介绍几种简单的文件加密方法,挺有意思的
- 使用VirtualBOX自带的共享文件夹功能
- Data Structures and algorithm analysis—1.2.4&1.2.5Modular Arithmeti&The P Word(数据结构—模数运算&P字)
- listView 的用法
- 如何获取 android 的系统日志 logcat
- onvif Analytics Service Specification---部分翻译
- MySQL菜鸟学习笔记
- 如何自学成才