CodeForces 651A Joysticks
水题。
#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; }