摘要: from fractions import Fraction as F while True: try: a = input() if a.find('+')!=-1: ls = a.split('+') print(F(ls[0]) + F(ls[1])) elif a.find('-')!=-1 阅读全文
posted @ 2022-05-31 17:15 kingwzun 阅读(55) 评论(0) 推荐(0) 编辑
摘要: from fractions import Fraction as F n=int(input()) for i in range(n): a = input() if a.find('+')!=-1: ls = a.split('+') print(F(ls[0]) + F(ls[1])) eli 阅读全文
posted @ 2022-05-31 17:13 kingwzun 阅读(466) 评论(0) 推荐(0) 编辑
摘要: #做法1: 使用内置函数Fraction from fractions import Fraction while True: try: a,b=map(int,input().split("/")) print(Fraction(a,b)) except: break 做法2:手写gcd **知识 阅读全文
posted @ 2022-05-31 16:53 kingwzun 阅读(174) 评论(0) 推荐(0) 编辑