码迷,mamicode.com
首页 > 其他好文 > 详细

CodeForces 651A Joysticks

时间:2016-03-08 09:14:50      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:

水题。

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <algorithm>
#include <ctime>
#include <stack>
using namespace std;
typedef long long LL;
const int maxn=1e5+9;
const int inf=1e9+9;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    int a,b;
    while(~scanf("%d%d",&a,&b))
    {
        LL cnt=0;
        while(1)
        {
            if(a==0 || b==0)
                break;
            if(a==1 && b==1)
                break;
            if(a>b)
            {
                b++;
                a-=2;
            }
            else
            {
                a++;
                b-=2;
            }
            cnt++;
        }
        printf("%I64d\n",cnt);
    }
    return 0;
}

 

CodeForces 651A Joysticks

标签:

原文地址:http://www.cnblogs.com/zufezzt/p/5252705.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!