摘要:
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 阅读全文
摘要:
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 阅读全文
摘要:
#做法1: 使用内置函数Fraction from fractions import Fraction while True: try: a,b=map(int,input().split("/")) print(Fraction(a,b)) except: break 做法2:手写gcd **知识 阅读全文