300 балов

This commit is contained in:
2025-12-05 12:00:09 +05:00
parent dcb80ef973
commit 0f5d961520

46
programm13.py Normal file
View File

@@ -0,0 +1,46 @@
def volodya_add(num1, num2):
"""Складывает два числа по алгоритму Володи"""
s1 = str(num1)
s2 = str(num2)
max_len = max(len(s1), len(s2))
s1 = s1.zfill(max_len)
s2 = s2.zfill(max_len)
result = ""
for i in range(max_len - 1, -1, -1):
digit_sum = int(s1[i]) + int(s2[i])
result = str(digit_sum) + result
return int(result)
with open('INPUT.TXT', 'r') as f:
a, b, c = map(int, f.readline().split())
results = set()
# (a + b) + c
results.add(volodya_add(volodya_add(a, b), c))
# (a + c) + b
results.add(volodya_add(volodya_add(a, c), b))
# (b + c) + a
results.add(volodya_add(volodya_add(b, c), a))
# a + (b + c)
results.add(volodya_add(a, volodya_add(b, c)))
# b + (a + c)
results.add(volodya_add(b, volodya_add(a, c)))
# c + (a + b)
results.add(volodya_add(c, volodya_add(a, b)))
sorted_results = sorted(results)
with open('OUTPUT.TXT', 'w') as f:
if len(results) > 1:
f.write("YES\n")
else:
f.write("NO\n")
for res in sorted_results:
f.write(str(res) + "\n")