Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Submit Status

Description

Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at a1 percent and second one is charged at a2 percent. You can connect charger to a joystick only at the beginning of each minute. In one minute joystick either discharges by 2 percent (if not connected to a charger) or charges by 1 percent (if connected to a charger).

Game continues while both joysticks have a positive charge. Hence, if at the beginning of minute some joystick is charged by 1 percent, it has to be connected to a charger, otherwise the game stops. If some joystick completely discharges (its charge turns to 0), the game also stops.

Determine the maximum number of minutes that game can last. It is prohibited to pause the game, i. e. at each moment both joysticks should be enabled. It is allowed for joystick to be charged by more than 100 percent.

Input

The first line of the input contains two positive integers a1 and a2 (1 ≤ a1, a2 ≤ 100), the initial charge level of first and second joystick respectively.

Output

Output the only integer, the maximum number of minutes that the game can last. Game continues until some joystick is discharged.

Sample Input

Input
3 5
Output
6
Input
4 4
Output
5
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
int a,b;
scanf("%d%d",&a,&b);
int ans=;
while(a>&&b>){
if(a==&&b==) break;
if(a>=b){
a-=;
b+=;
}else{
a+=;
b-=;
}
ans++;
}
printf("%d\n",ans);
return ;
}

codeforces 651a oysticks的更多相关文章

  1. CodeForces 651A Joysticks 贪心

    A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  2. 【CodeForces 651A】Joysticks 模拟

    题意:给定a,b,每个单位时间可以将a,b中一台加1,一台减2,求最久可以支持多久. #include <cstdio> #include <algorithm> using ...

  3. codeforces 651A Joysticks

    A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  4. codeforces 651A A. Joysticks (模拟)

    A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  5. Codeforces 651A Joysticks【贪心】

    题意: 两根操纵杆,每分钟操纵杆消耗电量2%,每分钟又可以给一个操纵杆充电1%(电量可以超过100%),当任何一个操纵杆电量降到0时,游戏停止.问最长游戏时间. 分析: 贪心,每次选择电量剩余最少的充 ...

  6. CodeForces 651A(水题)

    Friends are going to play console. They have two joysticks and only one charger for them. Initially ...

  7. [刷题codeforces]651B/651A

    651B Beautiful Paintings 651A Joysticks 点击可查看原题 651B是一个排序题,只不过多了一步去重然后记录个数.每次筛一层,直到全为0.从这个题里学到一个正确姿势 ...

  8. Codeforces Round #345(Div. 2)-651A.水题 651B.。。。 651C.去重操作 真是让人头大

    A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  9. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

随机推荐

  1. python基础--常用模块与面向对象基础

    1常用模块 1.1 xml xml是实现不同语言或程序之间进行数据交换的协议 xml的格式如下: <?xml version="1.0"?> <data> ...

  2. 显示图案 Exercise06_06

    import java.util.Scanner; /** * @author 冰樱梦 * 时间:2018年下半年 * 题目:显示图案 * 输入一个数 5 1 2 1 3 2 1 4 3 2 1 5 ...

  3. Java高级架构师(一)第03节:多模块多Web应用合并War包

    多模块.多Web应用合并war包 在日常的系统开发中,如果担心各个系统的资源同名覆盖,可以在总的War模块下放置一份最终的资源. 将版本号改成9.1.0.v20131115,ok 在Idea中的Mav ...

  4. IO流--字符流缓冲技术

    缓冲技术是为了提高数据的读写效率而提出的. (1)字符流的缓冲读 在字符流的缓冲技术中提供了一个newLine()方法,这个方法是跨平台的 在读数据的时候采用读完直接刷新的方式可以保证断电后数据不会丢 ...

  5. linux-去重-uniq

    uniq : 默认(去重)  |  -d(显重)   |   -u(删重) 语法:uniq  [选项]  文件 选项 -c或--count 在每列旁边显示该行重复出现的次数 -d或--repeat 仅 ...

  6. UdpClient类客户端和服务端demo

    服务端demo static IPEndPoint ipe = new IPEndPoint(IPAddress.Any, 0); static UdpClient udp = new UdpClie ...

  7. RocketMQ(7)——通信协议

    RocketMQ(7)——通信协议 RocketMQ的通信协议其实很简单,但是无论是官方的用户手册,还是网上的博客,并没有很清晰简单地把其中所有的内容和原理讲明白. 对于需要扩展其他语言SDK的开发来 ...

  8. telnet命令

    详细资料 telnet命令使用方法详解-telnet命令怎么用-win7没有telent怎么办 2017年07月26日 15:37:36 阅读数:1010 什么是Telnet? 对于Telnet的认识 ...

  9. WebForms UnobtrusiveValidationMode 须要“jquery”ScriptResourceMapping

    问题具体描写叙述信息:       异常具体信息:System.InvalidOperationException: WebForms                         Unobtrus ...

  10. 【CI】系列三.宿主机KVM配置及vdi与vmdk格式转换等

    前提:宿主机需要支持虚拟化,如果未打开,则需要重启机器,在bois中打开该项: Ubuntu 及 KVM 相关主要参考官方 https://wiki.ubuntu.com/kvm 另外也可参考该页面: ...