arrow_forward همه ارسال‌ها

جزئیات ارسال کد#225

code_blocks
مسئله مربوطه: ماراتون پینگ پنگ (#16) arrow_outward
verified
وضعیت داوری نهایی: محدودیت زمان تست 5
terminal
زبان برنامه‌نویسی: Python
schedule
ارسال‌کننده و زمان:
Mujtablue io (۳ سال پیش)
descriptionsolution.py ۲۷ خط • ۷۵۳ بایت
1bounce = 1
2ball = int(input())
3
4
5while ball > 1:
6 if (ball / 2).is_integer():
7## print(f"Cut {ball} in half")
8 bounce += 1
9 ball = int(ball / 2)
10 else:
11 potential_services = iter(range(ball - 1, 0, -1))
12 service = next(potential_services)
13 if (ball ** 0.5).is_integer():
14 bounce += 1
15 ball = int(ball ** 0.5)
16## print(f"{ball ** 2} Has a sqrt of {ball}")
17 else:
18 while True:
19 if not bool(ball % service):
20 bounce += 1
21 ball = service
22## print(f"service {ball}")
23 break
24 service = next(potential_services)
25
26
27print(bounce)
کد ارسال‌شده برای داوری خودکار هاتکدز UTF-8