import sys
#Time for gschem unit in ns
XU = 5.0
#Voltage for unit for ch 1 and 2 in mV
YU1 = 0.5
YU2 = 5.0
#Resistors 2 and 3 resistances in ohms
R2 = 983.0
R3 = 99.4
#Frequency in Hz
F = 30303.0
def getlist(list, x0, y0, invert):
for i in range(len(list)):
list[ i ][0] -= x0
list[ i ][2] -= x0
if (invert):
list[ i ][1] = y0 - list[ i ][1]
list[ i ][3] = y0 - list[ i ][3]
else:
list[ i ][1] -= y0
list[ i ][3] -= y0
return list
def gety(list, i, t):
lx = float(list[ i ][2] - list[ i ][0])
ly = float(list[ i ][3] - list[ i ][1])
dx = float(t - list[ i ][0])
dy = ly * abs(dx / lx)
return list[ i ][1] + dy
def output(s, e):
#Energy in uJ
e *= XU / 10 / 1000000
print("%s power was %.3f uW" % (s, F * e))
lines = []
for s in sys.stdin:
l = []
i1 = 1
if (s[0] != "L"): continue
for j in range(4):
i0 = i1 + 1
i1 = s.find(" ", i0)
l.append(int(s[i0:i1]))
lines.append(l)
x0 = lines[0][0]
y0 = lines[-2][1]
y1 = lines[-1][1]
lines.pop()
lines.pop()
i1 = map(lambda l: l[1] <= y0, lines).index(True)
i2 = map(lambda l: l[0] == x0, lines[1 : ]).index(True) + 1
ilist = getlist(lines[: i1], x0, y0, False)
olist = getlist(lines[i1 : i2], lines[i1][0], y0, True)
r2list = getlist(lines[i2 : ], lines[i2][0], y1, False)
e = 0.0
i1 = i2 = 0
for t in range(0, ilist[-1][2], 10):
if (t >= ilist[i1][2]): i1 += 1;
if (t >= r2list[i2][2]): i2 += 1;
ilr = gety(r2list, i2, t) * YU2 / R2
vlr = gety(ilist, i1, t) * YU1
plr = ilr * vlr / 1000
pr = vlr * vlr / R3 / 1000
pl = plr - pr
e += pl
output("Input", e)
e = 0.0
i1 = 0
for t in range(0, olist[-1][2], 10):
if (t >= olist[i1][2]): i1 += 1;
vlr = gety(olist, i1, t) * YU1
pr = vlr * vlr / R3 / 1000
e += pr
output("Output", e)
aW1wb3J0IHN5cwog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