1876. Centipede's Morning

Time limit: 0.5 second
Memory limit: 64 MB
A centipede has 40 left feet and 40 right feet. It keeps a left slippers
and b right slippers under its bed. Every morning the centipede puts on
the slippers. It pokes its first left foot under the bed and puts on a
random slipper, doing it in one second. If the slipper is left, the
centipede passes to shoeing the second left foot. Otherwise, it takes off
the slipper and puts it on any unshod right foot, spending one more
second, so that it takes two seconds altogether to put on such a slipper.
If there are no unshod right feet, the centipede throws the slipper to a
corner of the room, also in one second, so that two seconds are spent
altogether for this slipper. The process is continued until all the left
feet are in left slippers. Then the centipede starts shoeing its right
feet until all of them are shod.
Today the centipede has got out of bed on the wrong side, so it is
preparing for the worst. How many seconds will it need for shoeing?

Input

The only line contains the integers a and b (40 ≤ a, b ≤ 100).

Output

Output the number of seconds the centipede will need for shoeing in the
worst case.

Sample

input output
40 40
120
 #include<iostream>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
#include<deque>
#include<list>
using namespace std;
int main()
{
int a,b;
cin>>a>>b;
printf("%d",max(*b+,*a+));
return ;
}

URAL 1876 Centipede's Morning的更多相关文章

  1. URAL 1876 Centipede's Morning(数学)

    A centipede has 40 left feet and 40 right feet. It keeps a left slippers and b right slippers under ...

  2. BZOJ 1876: [SDOI2009]SuperGCD

    1876: [SDOI2009]SuperGCD Time Limit: 4 Sec  Memory Limit: 64 MBSubmit: 3060  Solved: 1036[Submit][St ...

  3. ZZULI 1876: 蛤玮的项链 Hash + 二分

    Time Limit: 6 Sec  Memory Limit: 128 MBSubmit: 153  Solved: 11 SubmitStatusWeb Board Description 蛤玮向 ...

  4. 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome

    题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...

  5. ural 2071. Juice Cocktails

    2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...

  6. ural 2073. Log Files

    2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...

  7. ural 2070. Interesting Numbers

    2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...

  8. ural 2069. Hard Rock

    2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...

  9. ural 2068. Game of Nuts

    2068. Game of Nuts Time limit: 1.0 secondMemory limit: 64 MB The war for Westeros is still in proces ...

随机推荐

  1. ASP.NET MVC 防止跨站请求伪造(CSRF)攻击的方法

    在HTTP POST请求中,我们多次在View和Controller中看下如下代码: View中调用了Html.AntiForgeryToken(). Controller中的方法添加了[Valida ...

  2. MVVM设计模式的事件绑定

    为什么要事件绑定 这个问题其实是很好理解的,因为事件是丰富多样的,单纯的命令绑定远不能覆盖所有的事件.例如Button的命令绑定能够解决Click事件的需求,但Button的MouseEnter.窗体 ...

  3. Python基础(2):__doc__、文档字符串docString、help()

    OS:Windows 10家庭中文版,Python:3.6.4 Python中的 文档字符串(docString) 出现在 模块.函数.类 的第一行,用于对这些程序进行说明.它在执行的时候被忽略,但会 ...

  4. TCP协议端口状态说明:CLOSE-WAIT、TIME-WAIT 、LISTENING、SYN_SENT、ESTABLISHED、LAST-ACK ...

    了解TCP协议端口的连接状态,对排除和定位网络或系统故障会有很大帮助,因此了解一下是有必要的: 一.LISTENING  提供某种服务,侦听远方TCP端口的连接请求,当提供的服务没有被连接时,处于LI ...

  5. Effective STL 学习笔记: Item 22 ~ 24

    Effective STL 学习笔记: Item 22 ~ 24 */--> div.org-src-container { font-size: 85%; font-family: monos ...

  6. wordpress 常用函数-wpdb类

    与数据库建立接口 WordPress为用户提供了一系列用于数据库操作的函数类——wpdb.Wpdb类建立在Justin Vincent编写并维护的ezSQL类的基础上. 使用须知 不可直接调用wpdb ...

  7. VS 2015 序列号/密钥/企业版/专业版

    专业版:HMGNV-WCYXV-X7G9W-YCX63-B98R2企业版:HM6NR-QXX7C-DFW2Y-8B82K-WTYJV

  8. Azkaban(二)CentOS7.5安装Azkaban

    1.软件介绍 Azkaban Web 服务器:azkaban-web-server-2.5.0.tar.gz Azkaban Excutor 执行服务器:azkaban-executor-server ...

  9. .NET异步多线程,Thread,ThreadPool,Task,Parallel,异常处理,线程取消

    今天记录一下异步多线程的进阶历史,以及简单的使用方法 主要还是以Task,Parallel为主,毕竟用的比较多的现在就是这些了,再往前去的,除非是老项目,不然真的应该是挺少了,大概有个概念,就当了解一 ...

  10. C#基础语法补充

    [学习笔记]前接:https://www.cnblogs.com/aland-1415/p/7360509.html 一.异常处理 1.格式 try{ } catch{ } catch{ } ... ...