zoukankan      html  css  js  c++  java
  • URAL 1876 Centipede's Morning

    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

    inputoutput
    40 40
    
    120
    
     1 #include<iostream>  
     2 #include<string.h>  
     3 #include<stdio.h>  
     4 #include<ctype.h>  
     5 #include<algorithm>  
     6 #include<stack>  
     7 #include<queue>  
     8 #include<set>  
     9 #include<math.h>  
    10 #include<vector>  
    11 #include<map>  
    12 #include<deque>  
    13 #include<list>  
    14 using namespace std;
    15 int main()
    16 {
    17     int a,b;
    18     cin>>a>>b;
    19     printf("%d",max(2*b+40,2*a+39));
    20     return 0;
    21 }  
    View Code
  • 相关阅读:
    Spring---入门
    Struts2---数据的校验
    Mybatis入门(二)增删改查
    解决pyinstaller打包后运行,出现ModuleNotFoundError: No module named 'pywt._extensions._cwt'
    Python打包方法——Pyinstaller CentOS下踩坑记录
    Spring Boot + kkFileView-2.1.2 实现文档在线预览
    Spring Boot 文件下载
    Spring Boot 文件上传
    Spring Boot 整合 Shiro+Thymeleaf
    Spring Boot 整合 Druid && 配置数据源监控
  • 原文地址:https://www.cnblogs.com/qscqesze/p/3854180.html
Copyright © 2011-2022 走看看