题解 | 仰望水面的歪
仰望水面的歪
https://www.nowcoder.com/practice/69f00fb8b2004e039097c57b43c33b90
import sys
# 求最大公约数
def gcd(a, b):
if b == 0:
return a
else:
return(gcd(b, a%b))
while 1:
try:
n, level = map(int, input().strip().split())
for i in range(n):
x, y, z = map(int, input().strip().split())
maxnum = gcd(gcd(x, y), 2*level-z)
print(f"{x//maxnum} {y//maxnum} {(2*level-z)//maxnum}")
except:
break
查看6道真题和解析