"""runda 3C: dodawanie"""
import sys
from io import StringIO
DEBUG = False
def debug(*args): print(*args) if DEBUG else None
input = '''
91
91
82
''' # exp 4
debug(input)
instream = StringIO(input.strip())
instream = instream if DEBUG else sys.stdin
aa, bb, cc = instream.read().split()
aa = [int(x) for x in aa]
bb = [int(x) for x in bb]
cc = [int(x) for x in cc]
xx = list(zip(aa, bb, cc))
hill = 0
cnt = 0
cnts = []
while xx:
a, b, c = xx.pop()
if a + b + hill == c:
cnt += 1
hill = 0
elif a + b + hill == 10 + c:
hill = 1
else:
cnts.append(cnt)
if hill == 1:
xx.append((a, b, c))
cnt = 0
hill = 0
cnts.append(cnt)
debug(cnts)
print(int(sum((x+1)*x/2 for x in cnts)))
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | """runda 3C: dodawanie""" import sys from io import StringIO DEBUG = False def debug(*args): print(*args) if DEBUG else None input = ''' 91 91 82 ''' # exp 4 debug(input) instream = StringIO(input.strip()) instream = instream if DEBUG else sys.stdin aa, bb, cc = instream.read().split() aa = [int(x) for x in aa] bb = [int(x) for x in bb] cc = [int(x) for x in cc] xx = list(zip(aa, bb, cc)) hill = 0 cnt = 0 cnts = [] while xx: a, b, c = xx.pop() if a + b + hill == c: cnt += 1 hill = 0 elif a + b + hill == 10 + c: hill = 1 else: cnts.append(cnt) if hill == 1: xx.append((a, b, c)) cnt = 0 hill = 0 cnts.append(cnt) debug(cnts) print(int(sum((x+1)*x/2 for x in cnts))) |
English