//贪心,注意特判即可
#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. cf478d 线性dp好题

    /* 给定r个红块,g个绿块,按要求堆放 问当堆放成最大高度时,有多少种可能的堆放方式 排列要求:1.第i行放i块 2.每行同色 首先当然要确定能够放置几行 设红块有r个,绿块有g个,那么放置h行需要 ...

  2. Git使用三:git的使用流程

    先创建仓库 创建一个文件夹,作为仓库使用 初始化仓库,在仓库目录的命令行下输入:git init 第一步:创建一个文件,并写入内容,这里写入内容的时候,要把编码设置为utf-8 第二步:输入命令将文件 ...

  3. Nginx详解二十七:Nginx架构篇之安全篇

    1.常见的恶意行为:爬虫行为和恶意抓取.资源盗用 解决方案: 基础防盗链功能:不让恶意用户能轻易爬去网站对外数据 secure_link_module模块:对数据安全性提高,加密验证和失效性,适合核心 ...

  4. Nginx详解一:Nginx基础篇之环境准备

    环境确认: 1.确认系统网络可用 2.确认yum源可用 3.确认关闭iptabkes规则 查看是否有iptabkes规则:iptables -L 如果有的话:iptables -F关闭 保险起见也看看 ...

  5. python DLL接口测试

    #coding=utf-8 import clr import sys import threading from itertools import permutations sys.path.app ...

  6. CHENGDU3-Restful API 接口规范、django-rest-framework框架

    Restful API 接口规范.django-rest-framework框架 问题:什么是API? 答:API是接口,提供url. 接口有两个用途: 为别人提供服务,前后端分离. 为什么使用前后端 ...

  7. C++ Primer 笔记——迭代器

    iostream迭代器 1.虽然iostream类不是容器,但是标准库定义了可以用于IO的迭代器.创建一个流迭代器的时候必须指定要读写的类型.我们可以对任何具有输入运算符(>>)的类型定义 ...

  8. Reactnative——安装React Navigation后无法运行项目

    运行 npm install --save react-navigation 后,运行 react-native run-android 报 解决方法: 1.react-native init Nav ...

  9. python---数学表达式的分析树实现

    先走一遍, 前面很多知道点,都串起来了. # coding = utf-8 # 使用列表实现栈的功能 class Stack: def __init__(self): self.items = [] ...

  10. exception: java.net.ConnectException: Connection refused; For more details see: http://wiki.apache.org/hadoop/ConnectionRefused

    1.虽然,不是大错,还说要贴一下,由于我运行run-example streaming.NetworkWordCount localhost 9999的测试案例,出现的错误,第一感觉就是Spark没有 ...