//贪心,注意特判即可
#include <iostream>
using namespace std;
int main()
{
int a,b,ans = ;
cin >> a >> b;
while(a+b > && (a != || b != ) && (a!= && b!=))
{
++ans;
if(a > b) {a -= ; b+=;}
else {a+=; b-=;}
}
cout << ans << endl;
return ;
}

codeforces651----A. Joysticks的更多相关文章

  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. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  3. CodeForces 651 A Joysticks

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

  4. Codeforces Round #345 (Div. 2) A. Joysticks dp

    A. Joysticks 题目连接: http://www.codeforces.com/contest/651/problem/A Description Friends are going to ...

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

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

  6. Codeforces Round #345 (Div. 2)——A. Joysticks(模拟+特判)

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

  7. 【CodeForces 651A】Joysticks 模拟

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

  8. Codeforces 651A Joysticks【贪心】

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

  9. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

随机推荐

  1. LeetCode(75):分类颜色

    Medium! 题目描述: 给定一个包含红色.白色和蓝色,一共 n 个元素的数组,原地对它们进行排序,使得相同颜色的元素相邻,并按照红色.白色.蓝色顺序排列. 此题中,我们使用整数 0. 1 和 2 ...

  2. bzoj2200拓扑排序+最短路+联通块

    自己写的不知道哪里wa了,明明和网上的代码差不多.,. /* 给定一张图,有的边是无向边,有的是有向边,有向边不会出现在环中,且有可能是负权值 现在给定起点s,求出s到其余所有点的最短路长度 任何存在 ...

  3. Python变量的作用域

    局部变量 局部变量是指在函数内部定义并使用的变量,他只在函数内部有效.即函数内部的名字只在函数运行时才会创建,在函数运行之前或者运行完毕之后,所有的名字就都不存在了.所以,如果在函数外部使用函数内部定 ...

  4. AI学习吧-REDIS-常识

    Redis 是一个non-sql,非关系型数据库,数据存放在内存中,支持持久化,redis中的数据会在一段时间内和(mysql等数据库)磁盘进行同步,防止丢失,这样也就降低了读数据效率. Redis和 ...

  5. python 内置数据类型之数字

    目录: 1.2. 数字 1.2.1. 数字类型 1.2.2. 浮点数 1.2.3. 进制记数 1.2.4. 设置小数精度 1.2.5. 分数 1.2.6. 除法 1.2 数字   1.2.1 数字类型 ...

  6. bootstrap-table 刷新页面数据

    bom.bootstrapTable('load',msg['object']);//这一步 务必要添加. if(msg['code']==1){ bom.find('tbody').css('dis ...

  7. Python函数之匿名函数

    一:概述 匿名函数主要用来处理比较简单的逻辑,用一行显示,并将运算结果作为返回值返回 二:书写规则 函数名 = lambda 参数:返回值 参数可以有多个,多个参数使用逗号分隔 三 :例子 将func ...

  8. .NoSuchBeanDefinitionException: No bean named 'userService' available

  9. 一脸懵逼学习Hdfs---动态增加节点和副本数量管理(Hdfs动态扩容)

    1:按照上篇博客写的,将各个进程都启动起来: 集群规划:    主机名        IP                安装的软件                    运行的进程   master ...

  10. proc/net/dev实时网速统计实例

    https://blog.csdn.net/dosthing/article/details/80384541 http://www.l99.com/EditText_view.action?text ...