zoukankan      html  css  js  c++  java
  • cf 581A— 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 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
    ",day,day1);
    38     return 0;
    39 }
    View Code
  • 相关阅读:
    Quartz入门例子简介 从入门到菜鸟(一)
    初识Quartz之第一个Quartz实例
    @DisallowConcurrentExecution 注解的作用 【定时器执行完当前任务才开启下一个线程的方式】
    no identities are available for signing
    Unity3D研究院之在把代码混淆过的游戏返混淆回来
    安沃广告问题
    IOS 接ShareSDK问题
    网页中插入Flvplayer视频播放器代码
    unity Android 打包后读取 xml 文件
    unity3d 下操作excel 与打印
  • 原文地址:https://www.cnblogs.com/forwin/p/4855130.html
Copyright © 2011-2022 走看看