P1618 三连击(升级版)

原题链接 https://www.luogu.com.cn/problem/P1618

题目描述

将数字 1 到 9 各用一次,拼成三个三位数,使它们的比例等于 A:B:C。

输入 一行给出 A、B、C。

输出 每个解占一行,按第一个三位数升序排列。无解时输出 No!!!。

输入输出样例

输入

1 2 3

输出

192 384 576
219 438 657
273 546 819
327 654 981

题解

from itertools import *
a,b,c=map(int,input().split())
if a==0:
    print('No!!!')
    exit()
t=0
for x in range(123,988):
    if x*b%a or x*c%a:
        continue
    else:
        y=x*b//a
        z=x*c//a
        s=str(x)+str(y)+str(z)
        if len(s)==9 and len(set(s))==9 and '0' not in s:
            print(x,y,z)
            t+=1



if t==0:
    print('No!!!')