小学奥数_7832 最接近的分数 python
生活随笔
收集整理的這篇文章主要介紹了
小学奥数_7832 最接近的分数 python
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
http://noi.openjudge.cn/math/7832/
""" 小學奧數_7832 最接近的分數 http://noi.openjudge.cn/math/7832/ https://blog.csdn.net/zqwang/article/details/79383618 https://blog.csdn.net/tigerisland45/article/details/71157783""" def gcd(x, y):m = max(x, y)n = min(x, y)while m%n:m, n = n, m%nreturn nn,a,b = map(int,input( ).split( )) p=1 q=nx=1 while x<=n:y=nwhile y>=1:if b*x<a*y and x*q>p*y:p=xq=yy-=1x+=1print(p//gcd(p,q),end=' ') print(q//gcd(p,q)) 創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的小学奥数_7832 最接近的分数 python的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: VirtualBox在win10下安装一
- 下一篇: 微信小程序消息推送自有服务器无法接收到信