From 0f5d961520a41a68bb5f5a74517b9e0d2abaa1b7 Mon Sep 17 00:00:00 2001 From: jze9 Date: Fri, 5 Dec 2025 12:00:09 +0500 Subject: [PATCH] =?UTF-8?q?300=20=D0=B1=D0=B0=D0=BB=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- programm13.py | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 programm13.py diff --git a/programm13.py b/programm13.py new file mode 100644 index 0000000..3bfd230 --- /dev/null +++ b/programm13.py @@ -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") \ No newline at end of file