Submit solution
Points:
100.00 (partial)
Time limit:
1.0s
Memory limit:
512M
Input:
stdin
Output:
stdout
Problem type
Allowed languages
Python, Scratch
In case the statement didn't load correctly, you can download the statement here: Statement
Comments
def gcd(a, b): if b==0: return a else: return gcd(b, a%b)
if name=='main': a, b, c=int(input()), int(input()), int(input()) ts, ms=min(a, b, c), max(a, b, c) div=gcd(ts, ms) ts//=div; ms//=div print(ts+ms)
def gcd(a, b): if b==0: return a else: return gcd(b, a%b)
if name=='main': a, b, c=int(input()), int(input()), int(input()) ts, ms=min(a, b, c), max(a, b, c) div=gcd(ts, ms) ts//=div; ms//=div print(ts+ms)
Code python nè:
def ucln(a, b): while b: a, b = b, a % b return a ds=[] for _ in range(3): ds.append(int(input()))
phansonhonhat = float('inf') tusonhonhat = -1 mausonho_nhat = -1
for i in range(3): for j in range(3): if i != j: tuso = ds[i] mauso = ds[j] giatriphanso = tuso / mau_so
uocchung = ucln(tusonhonhat, mausonhonhat) tusorutgon = tusonhonhat // uocchung mausorutgon = mausonhonhat // uoc_chung
print(tusorutgon + mausorutgon)
AI CÓ CODE scrach ko
cho mình xin
ai có bài làm scratch ko
Tìm số bé nhất và số lớn nhất,rút gọn rồi cộng lại là xong.
phân số bé nhất luôn là số bé nhất/số lớn nhất
mesiuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
???
Nếu phải sắp xếp các số thành các phân số khác nhau rồi tìm một phân số nhỏ nhất có thể, vậy thì thay vào đó phải tìm tử số nhỏ nhất và mẫu số lớn nhất trong các số đó (tử số càng nhỏ hoặc mẫu số càng lớn thì phân số càng nhỏ và ngược lại)
code python đây nhé ACE
code nay se ko chay nhanh tai math la thu vien tu C nhung ma mo ta ro hon ve tt Euclid : def _gcd(f1, f2): if f2: return _gcd(f2, f1 % f2) return f1
a = int(input()) b = int(input()) c = int(input()) m=min(a,b,c) mx=max(a,b,c) c=_gcd(m,mx) print(m//c+mx//c)
code nè mọi người: import math a=int(input()) b=int(input()) c=int(input()) ts=min(a,b,c) ms=max(a,b,c) k=math.gcd(ts,ms) ts=ts//k ms=ms//k print(ts+ms)
tìm số bé nhất và lớn nhất rồi rút gọn rồi cộng là ra
code nè
from fractions import * a = int(input()) b = int(input()) c = int(input()) num = 0 d = Fraction(a, b) e = Fraction(a, c) f = Fraction(b, c) g = Fraction(b, a) h = Fraction(c, a) k = Fraction(c, b) dd = d.numerator dd2 = d.denominator ee = e.numerator ee2 = e.denominator ff = f.numerator ff2 = f.denominator aa = min(d, e, f, g, h, k) if aa == d or aa == g: num = dd+dd2 elif aa == e or aa == h: num = ee+ee2 elif aa == f or aa == k: num = ff+ff2 print(num)
Cần gì phải dùng
fractions.Fraction
rườm rà thế kiaHint:
Dùng module fractions của Python
tử và mẫu có cần giống nhau không
Tìm min và max của 3 số a,b,c
là tìm min max rồi rút gọn, sau đó cộng với nhau hả bạn
a = int(input()) b = int(input()) c = int(input()) print(min(a,b,c)) print(max(a,b,c))
Ai biết cách làm thì chỉ mình với ạ! Cảm ơn mọi người rất nhiều