yixinnb @ 2023-08-22 17:45:50
问题数据 输入0 0 0
0.9s的时候输出no!!! 完美
if time.time()-start_time>0.9:
print("No!!!")
break
a b c 依次乘123456...
1-9不能重复=>python自带不可重复数组(set)
192 384 576=>192384576=>string=>char
set_.add(char)
退出循环条件
eg."1234567899"没有0且长度大于9=>必定存在重复
import time
a, b, c = input().split()
a = int(a)
b = int(b)
c = int(c)
x = 0
found=False
start_time=time.time()
while 1:
x += 1
if time.time()-start_time>0.9:
print("No!!!")
break
set_=set()
r = f"{a * x}{b * x}{c * x}"
if r.find("0")!=-1:continue
if len(r)>=10:
if found==False:
print("No!!!")
break
for char in r:
set_.add(char)
if len(set_)==9:
found=True
print(f"{a * x} {b * x} {c * x}")
by _Adolf_Hitler_ @ 2023-08-22 17:55:44
@yixinnb tlqtj,jbl
by Libingyue2011 @ 2023-08-22 17:56:06
python 速度较慢,再用上常数大的 set 肯定超时。
by yixinnb @ 2023-08-23 17:17:25
@Libingyue2011 不是超时 是死循环
by Libingyue2011 @ 2023-08-23 17:22:17
eee
by Martin07 @ 2023-09-10 16:26:38
优化一下