zoukankan      html  css  js  c++  java
  • cf581A Vasya the Hipster

    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 test(s)
    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.

    第一题太sb了就是手速题

     1 #include<set>
     2 #include<map>
     3 #include<cmath>
     4 #include<ctime>
     5 #include<deque>
     6 #include<queue>
     7 #include<bitset>
     8 #include<cstdio>
     9 #include<cstdlib>
    10 #include<cstring>
    11 #include<iostream>
    12 #include<algorithm>
    13 #define LL long long
    14 #define inf 0x7fffffff
    15 #define pa pair<int,int>
    16 #define pi 3.1415926535897932384626433832795028841971
    17 using namespace std;
    18 inline LL read()
    19 {
    20     LL x=0,f=1;char ch=getchar();
    21     while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    22     while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    23     return x*f;
    24 }
    25 int n,m;
    26 int main()
    27 {
    28     n=read(),m=read();
    29     int mx=min(n,m);
    30     n-=mx;m-=mx;
    31     if (n>m)swap(n,m);
    32     printf("%d %d
    ",mx,m/2);
    33 }
    cf581A
    ——by zhber,转载请注明来源
  • 相关阅读:
    Python语法入门01
    计算机基础入门
    小白初入Python人工智能
    python编译器的安装和pycharm的安装
    一个简单的例子,让你理解依赖注入
    分分钟教会大家第一个Spring入门案例
    白牌交换机:理想,现状与未来
    2017下一代数据中心网络研究报告
    pica8公司和picOS
    OCP(open compute project)
  • 原文地址:https://www.cnblogs.com/zhber/p/4845140.html
Copyright © 2011-2022 走看看