← Back to List

17944번: 퐁당퐁당 1 ↗

Solutions

Python 3
280 B | 280 chars
a,b=map(int,input().split())
chk = True
s = 0
while b>0:
    b-=1
    if chk:
        if s == 2*a:
            s-=1
            chk = False
        else:
            s+=1
    else:
        if s == 1:
            s+=1
            chk = True
        else:
            s-=1
print(s)