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,转载请注明来源
  • 相关阅读:
    6、深入理解计算机系统笔记:存储器层次结构,存储技术(1)
    流程图【占无内容】
    程序的三种基本控制架构【只有提纲】
    Console算法[for]穷举法:百钱买百鸡
    Logic算法(狼羊白菜)
    Console算法continue与break的区别?
    Console算法[for]简单画图
    Console算法[for]输出等腰三角形
    Console算法[for]国王与老人的六十四格
    Console算法[for]素数
  • 原文地址:https://www.cnblogs.com/zhber/p/4845140.html
Copyright © 2011-2022 走看看