题目链接:http://codeforces.com/problemset/problem/581/A

581A. Vasya the Hipster

time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

题目描述
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.

样例
Examples
Input
3 1
Output
1 1

Input
2 3
Output
2 0

Input
7 3
Output
3 2

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

题意:有a,b两种数量的袜子,问两只脚穿不同的袜子的最多天数,以及后面穿相同袜子的天数。

思路:找出a,b最小值,最小的值即为穿不同袜子的最多天数。最大的值减最小的值再除以2即为后面穿相同袜子的天数。

代码

#include<stdio.h>
int main()
{int a,b;scanf("%d%d",&a,&b);if(a>b){printf("%d %d\n",b,(a-b)/2);}else {printf("%d %d\n",a,(b-a)/2);}return 0;
}

A. Vasya the Hipster相关推荐

  1. 【Codeforces】A2组刷题记录(50 / 50)完结

    目录 A1. Counterexample A2. Good Number A3. Dice Tower ★A4. Alyona and Numbers A5. Mountain Scenery rz ...

  2. Codewars Vasya - Clerk--6 kyu--Python解法

    Codewars Vasya - Clerk–6 kyu–Python解法 Codewars 是一个跟LeetCode类似的结题网站. Codewars题解专栏:Codewars题解 题目地址:Tra ...

  3. Codeforces Round #281 (Div. 2) C. Vasya and Basketball 二分

    C. Vasya and Basketball 题目连接: http://codeforces.com/contest/493/problem/C Description Vasya follows ...

  4. Vasya and String CodeForces - 676C(尺取法)

    High school student Vasya got a string of length n as a birthday present. This string consists of le ...

  5. CodeForces - 1058D D. Vasya and Triangle

    D. Vasya and Triangle time limit per test1 second memory limit per test256 megabytes inputstandard i ...

  6. CodeForces 1058C C. Vasya and Golden Ticket

    C. Vasya and Golden Ticket time limit per test1 second memory limit per test256 megabytes inputstand ...

  7. java hipster!_通过Java Hipster升级Spring Security OAuth和JUnit测试

    java hipster! "我喜欢编写身份验证和授权代码." 〜从来没有Java开发人员. 厌倦了一次又一次地建立相同的登录屏幕? 尝试使用Okta API进行托管身份验证,授权 ...

  8. 【CodeForces - 1051C 】Vasya and Multisets (模拟)

    题干: Vasya has a multiset ss consisting of nn integer numbers. Vasya calls some number xxnice if it a ...

  9. 【CodeForces - 1051A】Vasya And Password (构造,水题)

    题干: Vasya came up with a password to register for EatForces - a string ss. The password in EatForces ...

  10. CF Edu54 E. Vasya and a Tree DFS+树状数组

    Vasya and a Tree 题意: 给定一棵树,对树有3e5的操作,每次操作为,把树上某个节点的不超过d的子节点都加上值x; 思路: 多开一个vector记录每个点上的操作.dfs这颗树,同时以 ...

最新文章

  1. sql中ifnull不生效_数据科学家常见的5个SQL面试问题
  2. 什么是通用字符名称?_通用名称
  3. 树形dp小胖守皇宫(vijosP1144)
  4. QT中的MessageBox设置自动关闭退出
  5. redis cluster中添加删除重分配节点例子
  6. 梦的解析 —— 梦知道答案
  7. 在windows7下安装pads2007.4
  8. 机器人码垛手持式编程_工业机器人的码垛编程方法
  9. 7-24 猜数字游戏 (15分)
  10. 微信屏蔽APP分享链接的解决方案原理,剖析微信域名防封技术
  11. 计算机视觉工具、代码合集
  12. 电脑休眠、睡眠、待机的区别
  13. tomcat系列-04-启用APR
  14. 【嵌入式开发教程7】手把手教你做平板电脑-音频驱动实验教程
  15. 单个应用流量统计实现和核对
  16. css3动画图片旋转绕轴,css3图片旋转如何实现?css3实现图片旋转动画效果的方法...
  17. CC2540 Large OAD实现程序无线升级
  18. 近代物理实验 液晶电光效应 (含数据和参考题)
  19. win7+64位笔记本安装TensorFlow CPU版
  20. 硬盘测试工具 CrystalDiskMark和Crystaldiskinfo

热门文章

  1. Unity 基于图像处理的图像显示特效制作过场特效
  2. Android瘦身优化
  3. AMP—Rover移植
  4. 全栈工程师就无敌吗?真的能做到个人即团队吗?
  5. (转)隐藏在生活里的量化投资密码
  6. python中idle什么意思_始学Python:IDLE环境介绍
  7. 用户自定义个性域名范解析
  8. html5 canvas实现桌面效果,基于html5 canvas实现漫天飞雪效果的方法
  9. H3C认证安全技术高级工程师
  10. 把时间当作朋友 读书笔记