题目:

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

Input
3 1

Output
1 1

Input
2 3

Output
2 0

Input
7 3

Output
3 2题目大意: 给你一定数目的两种颜色的袜子(红色和蓝色)书n和m;让你将不同颜色的袜子配对输出这个数,然后将同色的袜子看能凑几双,输出这个数。解析: 水。。

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<algorithm>
 4 using namespace std;
 5 int main()
 6 {
 7     int n,m;
 8     cin>>n>>m;
 9     int day=0,day1=0;
10     int sum=n+m;
11     if(sum%2==0)
12     {
13         if(n<m)
14         {
15             day=day+n;
16             day1+=(m-n)/2;
17         }
18         else
19         {
20             day+=m;
21             day1+=(n-m)/2;
22         }
23     }
24     else
25     {
26         if(n<m)
27         {
28             day=day+n;
29             day1+=(m-n-1)/2;
30         }
31         else
32         {
33             day+=m;
34             day1+=(n-m-1)/2;
35         }
36     }
37     printf("%d %d\n",day,day1);
38     return 0;
39 }

View Code

转载于:https://www.cnblogs.com/forwin/p/4855130.html

cf 581A— 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. CF Edu54 E. Vasya and a Tree DFS+树状数组

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

  3. cf Educational Codeforces Round 48 C. Vasya And The Mushrooms

    原题: C. Vasya And The Mushrooms time limit per test2 seconds memory limit per test256 megabytes input ...

  4. 【CF EDU59 E】 Vasya and Binary String (DP)

    题意 给一串01串,对该串进行若干次操作,直到串为空 操作为:选择一段连续的0或者1,删除它,拼接前后两部分成为新串,得到价值为a[删除的长度](a为给定的数组) 思路 一个非常规的DP 考虑题目所给 ...

  5. [CF1107E]Vasya and Binary String【区间DP】

    题目描述 Vasya has a string s of length n consisting only of digits 0 and 1. Also he has an array a of l ...

  6. cf Educational Codeforces Round 133 C. Robot in a Hallway

    原题: There is a grid, consisting of 2 rows and m columns. The rows are numbered from 1 to 2 from top ...

  7. 『参考』.net CF组件编程(4)——为自定义组件添加工具箱图标!

    前言: 在前三篇的文章中,和大家一起创建了一个用于TCP连接检测的小组件,如果你记不得了,可以通过以下链接去回顾一下: 『参考』.net CF组件编程(1)--基础之后 『参考』.net CF组件编程 ...

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

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

  9. OC对象 vs CF对象

    2019独角兽企业重金招聘Python工程师标准>>> OC对象 vs CF对象 在ARC场景下,对象所有权没有转换 使用__bridge关键字即可实现CF对象和OC对象之间的自由转 ...

  10. CF 990A. Commentary Boxes【数学/模拟】

    [链接]:CF [题意]:对于一个数n,每次加一的代价是a,每次减一的代价是b,求被m整除时的最小代价. [分析]:分情况讨论,自己多举几个栗子. [代码]: #include<cstdio&g ...

最新文章

  1. 【jQuery】选择器
  2. 【光环板】更新硬件方案最近找到的一些光环板资料,硬件方案及原理图
  3. 怪怪设计论闲谈篇:职责与解耦的矛盾
  4. Latex排版全解(转)
  5. java 加法 溢出_StackOverflow热帖:Java整数相加溢出怎么办?Java8一步搞定~
  6. 从零实现深度学习框架——N-Gram语言模型(一)
  7. Eclipse Community Survey 2012
  8. 活跃android手机,谁能升级2.3?Android手机活跃榜
  9. logistic人口模型python代码_人口模型(马尔萨斯--vs--logistic).ppt
  10. 布控球可接入电网安全接入平台及电网统一视频
  11. 【高级篇 / DNS】(7.0) ❀ 03. FortiGate作为Window DNS的备用DNS服务器 ❀ FortiGate 防火墙
  12. java epics_EPICS超入门-KEKe+e-.PDF
  13. 详解Linux内核IO技术栈
  14. 微信公众号代运营公司哪家好?
  15. 基于TCP/IP协议 区别 GET和POST
  16. 避坑,在Jetson nano安装编辑openpose
  17. 江南大学计算机科学专业排名,江南大学热门专业排名
  18. 把Firfox的缓冲设置到内存盘
  19. 软件设计师笔记----计算机组成与结构
  20. C/C++实习面试(一)

热门文章

  1. 六爻金钱卦 手工摇卦方法
  2. Harbor离线安装
  3. vscode 脑图插件mindmap
  4. 3.28Javase笔记day01
  5. 两个数组合成一个json对象_js把两个json数组根据相同键值合并成一个数组
  6. 茶酒“银行”的梦醒时分
  7. fillRect 就是rect+fill的结合体(canvas)
  8. 基于android的影音设计,基于Android系统的影音播放器设 - 音响技术 - 电子发烧友网...
  9. codeforces 1562 A. The Miracle and the Sleeper
  10. imo教我们的互联网思维9大玩法