Learn Python from a young age! Record the questions in the Luogu Python learning and exam preparation process, and record every moment.
Attached is a summary post: Luogu’s Python language | Summary_Blog of a communicator who loves programming-CSDN Blog
[Title description]
Input a set of Pythagorean numbers a, b, c ( a≠b≠c ), and output the sine value of its smaller acute angle in fractional format. (Ask for score.)
【enter】
A row contains three positive integers, namely the Pythagorean numbers a, b, c (in no order of magnitude).
【Output】
A row containing a fraction, the sine of the smaller acute angle
【Input sample】
3 5 4
【Output sample】
3/5
[Detailed code explanation]
import math # 因为后面要用到求最大公约数的函数,所以这里导入math库
a = [int(i) for i in input().split()] # 使用列表推导式记录三个正整数
a = sorted(a) # 按照从小到大方式对列表进行排序
print("%d/%d" % ((a[0]/math.gcd(a[0], a[2])), (a[2]/math.gcd(a[0], a[2])))) # 打印较小锐角的正弦值,即最小的边长除以最大的边长,注意是约分后的数
【operation result】
3 5 4
3/5