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. redis数据淘汰机制

    volatile-lru:从已设置过期时间的数据集(server.db[i].expires)中挑选最近最少使用 的数据淘汰 volatile-ttl:从已设置过期时间的数据集(server.db[i ...

  2. 【前端vue开发】vue单页应用添加百度统计

    前言 申请百度统计后,会得到一段JS代码,需要插入到每个网页中去,在Vue.js项目首先想到的可能就是,把统计代码插入到index.html入口文件中,这样就全局插入,每个页面就都有了;这样做就涉及到 ...

  3. 洛谷P2886牛继电器

    传送门啦 倍增 $ Floyd $ 注意结构体里二维数组不能开到 $ 2000 $ #include <iostream> #include <cstdio> #include ...

  4. JS Ajax异步请求发送列表数据后面多了[]

    还在苦逼的写代码,这里就不详细了,直接抛出问题: 如图所示: 前端ajax请求向后端发送数据的时候,给key添加了[]出现很多找不到原因, 后面在说 解决方法: 暂时先这样记录一下,下次方便查找,好了 ...

  5. Tetris:pygame实现

    网上搜到一个Pygame写的俄罗斯方块(tetris),大部分看懂的前提下增加了注释,Fedora19下运行OK的 主程序: #coding:utf8 #! /usr/bin/env python # ...

  6. CF GYM100548 (相邻格子颜色不同的方案数 2014西安现场赛F题 容斥原理)

    n个格子排成一行,有m种颜色,问用恰好k种颜色进行染色,使得相邻格子颜色不同的方案数. integers n, m, k (1 ≤n, m ≤ 10^9, 1 ≤ k ≤ 10^6, k ≤ n, m ...

  7. linux虚拟机磁盘不够用以及进行扩容时遇到的问题

    我使用的是:gparted live cd工具  系统是centOS6.2 使用gparted live cd工具进行无损分区,方法很简单,下载iso文件都在VMware对应的linux系统上设置CD ...

  8. 【LOJ】#2061. 「HAOI2016」放棋子

    题解 水题,可惜要写高精度有点烦 一看障碍物的摆放方式和最后的答案没有关系,于是干脆不读了,直接二项式反演可以得到 设\(g_k\)为一种摆放方式恰好占了k个障碍物 \(f_k = \sum_{i = ...

  9. Bootstrap进阶一:Glyphicons 字体图标

    基本组件是Bootstrap的精华之一,其中都是开发者平时需要用到的交互组件.例如:网站导航.标签页.工具条.面包屑.分页栏.提示标签.产品展示.提示信息块和进度条等.这些组件都配有jQuery插件, ...

  10. 32:从1到n整数中1出现的次数

    import java.util.Arrays; /** * 面试题32:从1到n整数中1出现的次数 求出1~13的整数中1出现的次数,并算出100~1300的整数中1出现的次数? * 为此他特别数了 ...