题解 | #将真分数分解为埃及分数#

将真分数分解为埃及分数

http://www.nowcoder.com/practice/e0480b2c6aa24bfba0935ffcca3ccb7b

while True:
try:
nums = list(map(int,input().strip().split('/')))
st = ''
base = int(nums[1]/nums[0])
while True:
nums1_buf = nums[1]base
if nums[0]
base > nums[1]:
nums[0] = nums[0]base - nums[1]
nums[1] = nums1_buf
st = st + '1/%d+' % base
base = int(nums[1]/nums[0])
elif nums[0]
base == nums[1]:
st = st + '1/%d' % base
break
else:
base = base + 1
print(st)
except EOFError:
break

全部评论

相关推荐

06-17 21:57
门头沟学院 Java
白友:噗嗤,我发现有些人事就爱发这些,明明已读不回就行了,就是要恶心人
点赞 评论 收藏
分享
06-19 14:58
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务