Joysticks
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? 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;} }?
總結(jié)
- 上一篇: Bear and Finding Cri
- 下一篇: 回溯法(深度优先搜索)