Joysticks
题链接:http://codeforces.com/problemset/problem/651/A
第一次没考虑到a1和a2都为1的情况
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
int a1,a2;
while(scanf("%d%d",&a1,&a2)!=EOF){
int ans = 0;
while(1){
if(a1<1||a2<1||(a1==1&&a2==1)) break;
else if(a1>=a2){
a1-=2;a2+=1;
ans++;
}
else{
a1+=1;a2-=2;
ans++;
}
}
cout << ans << endl;
}
}