codeforces--651A Joysticks(贪心)

来源:互联网 发布:虚拟机mac安装xcode 编辑:程序博客网 时间:2024/05/01 14:07

题解

贪心:每次都选择电量更小的那个进行充电。
注意:初始都为1的时候。

a, b = [int(x) for x in input().split()]ans = 1while a > 2 or b > 2:    if a > b: a, b = b, a    a += 1    b -= 2    ans += 1if a == 1 and b == 1: ans = 0print(ans)
0 0