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. TCP检验和

    TCP的检验和   检验和目的 目的是为了发现TCP首部和数据在发送端到接收端之间发生的任何改动.如果接收方检测到检验和有差错,则TCP段会被直接丢弃. TCP在计算检验和时,要加上一个12字节的伪首 ...

  2. mvc 分部视图(Partial)显示登陆前后变化以及Shared文件夹在解决方案资源管理器中没有显示的问题

    刚开始我的解决方案资源管理器中没有显示Shared文件夹,但Shared文件夹在项目中是实际存在的,我搜了下好像没有类似的解答(可能是我搜索的关键词不够准确).后来自己看了下vs2012. 其实解决方 ...

  3. Maven3 生命周期与插件(笔记五)

    第一节:Maven 生命周期 Maven 生命周期简介:Maven 通过插件的方式完成一系列过程来实现功能. Maven 拥有三套独立的生命周期: Clean 清理项目 Default 构建项目 Si ...

  4. the server ssl certificate failed to verify

    很久没上传项目之后,远程端断开联系 如果是git,就git clone,重新把项目拉下来. svn的话,就svn ls,拉下项目.

  5. 触发器中的inserted表和deleted表

    触发器语句中使用了两种特殊的表:deleted 表和 inserted 表.Microsoft? SQL Server 2000 自动创建和管理这些表.可以使用这两个临时的驻留内存的表测试某些数据修改 ...

  6. nginx + tomcat 集群记录

    昨天晚写的时候已经下班了.时间紧迫.写的略简! 昨天说过.接到部署的任务之后.首先想到的是apache httpserver 毕竟pache.我们接触的比较多!然而部署之后遇到了很多问题.比如apac ...

  7. 【剑指Offer面试题】 九度OJ1389:变态跳楼梯

    转自:http://www.myexception.cn/program/1973966.html 时间限制:1 秒内存限制:32 兆特殊判题:否提交:2331解决:1332 题目描述: 一只青蛙一次 ...

  8. appium----adb shell输入中文/Emoji表情符(ADBKeyBoard)

    前序 “adb shell input textyoyo“ 可以通过adb 输入英文的文本,由于不支持unicode编码,所以无法输入中文,github上有个国外的大神写了个ADBKeyBoard输入 ...

  9. ***codeigniter操作xml(Simplexml第三方扩展)

    This Simplexml class provides an alternative implementation of the SimpleXML API that works under PH ...

  10. 铁轨(UVa 514)

    利用栈实现 C++11 代码如下: #include<iostream> #include<stack> using namespace std; #define maxn 1 ...