题解 | #游游的整数切割#

游游的整数切割

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

str=input().strip()
total=0
odd_even=0
# 只用判断最后一位以及每一位的奇偶性就好,因为最后一位一直都是第二位的最后一位
if int(str[-1])%2==0:
    odd_even = 1
for i in range(len(str)-1):
    if odd_even == 0 and int(str[i])%2 !=0:
        total+=1
    if odd_even == 1 and int(str[i])%2 ==0:
        total+=1
print(total)

全部评论

相关推荐

04-08 23:37
已编辑
东华大学 结构工程师
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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