URAL 1876 Centipede's Morning
1876. Centipede's Morning
Memory limit: 64 MB
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.
preparing for the worst. How many seconds will it need for shoeing?
Input
Output
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的更多相关文章
- 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 ...
- BZOJ 1876: [SDOI2009]SuperGCD
1876: [SDOI2009]SuperGCD Time Limit: 4 Sec Memory Limit: 64 MBSubmit: 3060 Solved: 1036[Submit][St ...
- ZZULI 1876: 蛤玮的项链 Hash + 二分
Time Limit: 6 Sec Memory Limit: 128 MBSubmit: 153 Solved: 11 SubmitStatusWeb Board Description 蛤玮向 ...
- 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome
题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...
- ural 2071. Juice Cocktails
2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...
- ural 2073. Log Files
2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...
- ural 2070. Interesting Numbers
2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...
- ural 2069. Hard Rock
2069. Hard Rock Time limit: 1.0 secondMemory limit: 64 MB Ilya is a frontman of the most famous rock ...
- 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 ...
随机推荐
- openjudge-NOI 2.5-1700 八皇后问题
题目链接:http://noi.openjudge.cn/ch0205/1700/ 题解: 经典深搜题目…… #include<cstdio> ][]; int num; void pri ...
- jmert jdbc request支持执行多条sql语句并设置jdbc字符集
1.jdbc request支持执行多条sql语句 在JDBC Connection Configuration中的sql连接字串中添加如下内容 allowMultiQueries=true 如下图: ...
- No.14 selenium for python table表单
table表单,HTML中的特征 标识性标签:table.tr.th.td 定位使用Xpath定位 点击表格中的元素即可
- thinkphp5 url传参
url('index/blog/read',['id'=>5,'name'=>'thinkphp']); 手册https://www.kancloud.cn/manual/thinkphp ...
- elasticsearch学习笔记--原理介绍
前言:上一篇中我们对ES有了一个比较大概的概念,知道它是什么,干什么用的,今天给大家主要讲一下他的工作原理 介绍:ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户 ...
- SQL中EXCEPT和Not in的区别?
初始化两张表: CREATE TABLE tb1(ID int) INSERT tb1 SELECT NULLUNION ALL SELECT NULLUNION ...
- mysql热数据加载管理
5.6版本之后,提供了一个新特性来快速预热buffer_pool缓冲池.在my.cnf里面加入几个参数: innodb_buffer_pool_dump_at_shutdown = 1 --在关闭 ...
- 非ROOT用户不能识别声卡问题
将非ROOT用户加入到audio组中即可 sudo usermod -a -G audio usrname
- 【LOJ】#2320. 「清华集训 2017」生成树计数
题解 我,理解题解,用了一天 我,卡常数,又用了一天 到了最后,我才发现,我有个加法取模,写的是while(c >= MOD) c -= MOD 我把while改成if,时间,少了 六倍. 六倍 ...
- Django实战(10):单元测试
尽早进行单元测试(UnitTest)是比较好的做法,极端的情况甚至强调“测试先行”.现在我们已经有了第一个model类和Form类,是时候开始写测试代码了. Django支持python的单元测试(u ...