python的,还是有两个点没通过,有大佬帮忙看看吗谢谢

P1618 三连击(升级版)

lzysxfcs @ 2024-04-09 22:55:21

A, B, C = map(int, input().split())
found_solution = False
for i in range(100, 1000):
    two = B // A * i
    three = C // A * i
    if two < 1000 and three < 1000 and set(str(i) + str(two) + str(three)) == {'1', '2', '3', '4', '5', '6', '7', '8', '9'}:
        print(i, two, three)
        found_solution = True
if not found_solution:
    print('No!!!')

by lzysxfcs @ 2024-04-10 21:54:57

A, B, C = map(int, input().split())
found_solution = False
# 遍历所有的三位数,作为第一个数
for i in range(123, 988):  # 保证至少留有两位数的空间给后两个数
    two = i * B // A  # 计算第二个数
    three = i * C // A  # 计算第三个数
    # 确保two和three都是三位数
    if 99< two < 1000 and 99< three < 1000:
        # 检查这九个数字是否恰好是1到9
        if set(str(i) + str(two) + str(three)) == {'1', '2', '3', '4', '5','6', '7', '8', '9'}:
            print(i, two, three)
            found_solution = True
if not found_solution:
    print('No!!!')

代码改成这样之后第一个点还是RE了,但是得了100分,搞不懂为什么,大佬求解谢谢


by setvt @ 2024-04-17 17:51:30

因为 A 可能是0,加一个判断就可以了


by lzysxfcs @ 2024-04-18 07:18:21

@setvt 应该不是,因为题目说了A<B<C


|