文章

310

粉丝

0

获赞

130

访问

21.7k

头像
Primary Arithmetic 题解:
P1251 北京大学机试题
发布于2026年2月6日 18:39
阅读数 63

while(1):
    try:
        num = list(map(int, input().split()))
        a = num[0]
        b = num[1]
        op = 0
        count = 0
        while (a or  b or op):
            k1 = a % 10
            k2 = b % 10
            if (k1 + k2 + op >= 10):
                count += 1
                op = 1
            else:
                op=0
            a = a // 10
            b = b // 10
        if (count == 0):
            print("NO carry operation.")
        else:
            if(count==1):
                
                print("%d carry operation."%count)
            else:
                print("%d carry operations." % count)
    except:
        break
登录查看完整内容


登录后发布评论

暂无评论,来抢沙发