题解 | Number Steps

Number Steps

https://www.nowcoder.com/practice/e3d8d4dd9ec740f9b1e7fc1e8574ba21

#n = int(input())
a = 2
b = 0
c1 = 0
c = 0
#for  i in range(n):
x, y = list(map(int, input().split()))
if x == 0 and y == 0:
    print(0)
elif x == 2 and y == 0:
    print(2)
    
elif x-2 == y:
    while y:
        y -= 1
        c += 1
        if c % 2 != 0:
            a += 1
        else:
            a += 3
    print(a)
elif x == y:
        # y -= 1
    while y:
        y -= 1
        c1 += 1
        if c1 % 2 != 0:
            b += 1
        else:
            b += 3
    print(b)
else:
    print("No Number")
    

全部评论

相关推荐

08-25 14:25
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务