s_id stringlengths 10 10 | p_id stringlengths 6 6 | u_id stringlengths 10 10 | date stringlengths 10 10 | language stringclasses 1
value | original_language stringclasses 11
values | filename_ext stringclasses 1
value | status stringclasses 1
value | cpu_time stringlengths 1 5 | memory stringlengths 1 7 | code_size stringlengths 1 6 | code stringlengths 1 539k |
|---|---|---|---|---|---|---|---|---|---|---|---|
s304999486 | p02273 | u970436839 | 1452684526 | Python | Python | py | Runtime Error | 0 | 0 | 530 | def koch(n, a, b):
if n == 0:
return
s[0] = (2*a[0]* + b[0])/3
s[1] = (2*a[1]* + b[1])/3
t[0] = (a[0]* + 2*b[0])/3
t[1] = (a[1]* + 2*b[1])/3
u[0] = (t[0] - s[0])*cos(pi/3) - (t[1] - s[1])*sin(pi/3) + s[0]
u[1] = (t[0] - s[0])*sin(pi/3) + (t[1] - s[1])*cos(pi/3) + s[1]
koch(n-1, a, s)
print s[0], s[1]
koch(n-1, s, u)
print u[0], u[1]
koch(n-1, u, t)
print t[0], t[1]
koch(n-1, t, b)
n = input()
p1[0] = 0
p1[1] = 0
p2[0] = 100
p2[1] = 0
print p1[0], p2[1]
koch(n, p1, p2)
print p1[0], p2[1] |
s407591561 | p02273 | u970436839 | 1452685013 | Python | Python | py | Runtime Error | 0 | 0 | 534 | def koch(n, a, b):
if n == 0:
return
s[0] = (2*a[0] + b[0])/3
s[1] = (2*a[1] + b[1])/3
t[0] = (a[0] + 2*b[0])/3
t[1] = (a[1] + 2*b[1])/3
u[0] = (t[0] - s[0])*cos(pi/3) - (t[1] - s[1])*sin(pi/3) + s[0]
u[1] = (t[0] - s[0])*sin(pi/3) + (t[1] - s[1])*cos(pi/3) + s[1]
koch(n-1, a, s)
print s[0], s[1]
koch(n-1, s, u)
print u[0], u[1]
koch(n-1, u, t)
print t[0], t[1]
koch(n-1, t, b)
n = input()
p1[0] = 0.0
p1[1] = 0.0
p2[0] = 100.0
p2[1] = 0.0
print p1[0], p1[1]
koch(n, p1, p2)
print p2[0], p2[1] |
s739591119 | p02273 | u970436839 | 1452685171 | Python | Python | py | Runtime Error | 0 | 0 | 531 | def koch(n, a, b):
if n == 0:
return
s[0] = (2*a[0] + b[0])/3
s[1] = (2*a[1] + b[1])/3
t[0] = (a[0] + 2*b[0])/3
t[1] = (a[1] + 2*b[1])/3
u[0] = (t[0] - s[0])*cos(pi/3) - (t[1] - s[1])*sin(pi/3) + s[0]
u[1] = (t[0] - s[0])*sin(pi/3) + (t[1] - s[1])*cos(pi/3) + s[1]
koch(n-1, a, s)
print s[0], s[1]
koch(n-1, s, u)
print u[0], u[1]
koch(n-1, u, t)
print t[0], t[1]
koch(n-1, t, b)
n = input()
p1[0] = 0.0
p1[1] = 0.0
p2[0] = 100.0
p2[1] = 0.0
print p1[0], p1[1]
koch(n, p1, p2)
print p2[0], p2[1] |
s739564823 | p02273 | u970436839 | 1452686361 | Python | Python | py | Runtime Error | 0 | 0 | 590 | class coordinates:
def __init__(self, x, y):
self.x = x
self.y = y
def koch(n, a, b):
if n == 0:
return
s = coordinates((2*a[0] + b[0])/3, (2*a[1] + b[1])/3)
t = coordinates((a[0] + 2*b[0])/3, (a[1] + 2*b[1])/3)
ux = (t.x - s.x)*cos(pi/3) - (t.y - s.y)*sin(pi/3) + s.x
uy = (t.x - s.y)*sin(pi/3) + (t.y - s.y)*cos(pi/3) + s.y
koch(n-1, a, s)
print s.x, s.y
koch(n-1, s, u)
print u.x, u.y
koch(n-1, u, t)
print t.x, t.y
koch(n-1, t, b)
n = input()
p1 = point(0.0, 0.0)
p2 = point(100.0, 0.0)
print p1.x, p1.y
koch(n, p1, p2)
print p2.x, p2.y |
s898048096 | p02273 | u970436839 | 1452686411 | Python | Python | py | Runtime Error | 0 | 0 | 582 | class coordinates:
def __init__(self, x, y):
self.x = x
self.y = y
def koch(n, a, b):
if n == 0:
return
s = coordinates((2*a.x + b.x)/3, (2*a.y + b.y)/3)
t = coordinates((a.x + 2*b.x)/3, (a.y + 2*b.y)/3)
ux = (t.x - s.x)*cos(pi/3) - (t.y - s.y)*sin(pi/3) + s.x
uy = (t.x - s.y)*sin(pi/3) + (t.y - s.y)*cos(pi/3) + s.y
koch(n-1, a, s)
print s.x, s.y
koch(n-1, s, u)
print u.x, u.y
koch(n-1, u, t)
print t.x, t.y
koch(n-1, t, b)
n = input()
p1 = point(0.0, 0.0)
p2 = point(100.0, 0.0)
print p1.x, p1.y
koch(n, p1, p2)
print p2.x, p2.y |
s722653457 | p02273 | u970436839 | 1452686451 | Python | Python | py | Runtime Error | 0 | 0 | 602 | class coordinates:
def __init__(self, x, y):
self.x = x
self.y = y
def koch(n, a, b):
if n == 0:
return
s = coordinates((2*a.x + b.x)/3, (2*a.y + b.y)/3)
t = coordinates((a.x + 2*b.x)/3, (a.y + 2*b.y)/3)
ux = (t.x - s.x)*cos(pi/3) - (t.y - s.y)*sin(pi/3) + s.x
uy = (t.x - s.y)*sin(pi/3) + (t.y - s.y)*cos(pi/3) + s.y
u = point(ux, uy)
koch(n-1, a, s)
print s.x, s.y
koch(n-1, s, u)
print u.x, u.y
koch(n-1, u, t)
print t.x, t.y
koch(n-1, t, b)
n = input()
p1 = point(0.0, 0.0)
p2 = point(100.0, 0.0)
print p1.x, p1.y
koch(n, p1, p2)
print p2.x, p2.y |
s599581097 | p02273 | u970436839 | 1452686514 | Python | Python | py | Runtime Error | 10 | 6380 | 620 | class coordinates:
def __init__(self, x, y):
self.x = x
self.y = y
def koch(n, a, b):
if n == 0:
return
s = coordinates((2*a.x + b.x)/3, (2*a.y + b.y)/3)
t = coordinates((a.x + 2*b.x)/3, (a.y + 2*b.y)/3)
ux = (t.x - s.x)*cos(pi/3) - (t.y - s.y)*sin(pi/3) + s.x
uy = (t.x - s.y)*sin(pi/3) + (t.y - s.y)*cos(pi/3) + s.y
u = coordinates(ux, uy)
koch(n-1, a, s)
print s.x, s.y
koch(n-1, s, u)
print u.x, u.y
koch(n-1, u, t)
print t.x, t.y
koch(n-1, t, b)
n = input()
p1 = coordinates(0.0, 0.0)
p2 = coordinates(100.0, 0.0)
print p1.x, p1.y
koch(n, p1, p2)
print p2.x, p2.y |
s775477521 | p02273 | u970436839 | 1452687189 | Python | Python | py | Runtime Error | 10 | 6376 | 625 | class coordinates:
def __init__(self, x, y):
self.x = x
self.y = y
def koch(n, a, b):
if n == 0:
return
s = coordinates((2*a.x + b.x)/3, (2*a.y + b.y)/3)
t = coordinates((a.x + 2*b.x)/3, (a.y + 2*b.y)/3)
ux = (t.x - s.x)*cos(pi/3) - (t.y - s.y)*sin(pi/3) + s.x
uy = (t.x - s.x)*sin(pi/3) + (t.y - s.y)*cos(pi/3) + s.y
u = coordinates(ux, uy)
koch(n-1, a, s)
print s.x, s.y
koch(n-1, s, u)
print u.x, u.y
koch(n-1, u, t)
print t.x, t.y
koch(n-1, t, b)
n = input()
p1 = coordinates(0.0, 0.0)
p2 = coordinates(100.0, 0.0)
print p1.x, p1.y
koch(n, p1, p2)
print p2.x, p2.y |
s567906264 | p02273 | u970436839 | 1452687414 | Python | Python | py | Runtime Error | 10 | 6484 | 649 | class coordinates:
def __init__(self, x, y):
self.x = x
self.y = y
def koch(n, a, b):
if n == 0:
return
s = coordinates((2.0*a.x + b.x)/3.0, (2.0*a.y + b.y)/3.0)
t = coordinates((a.x + 2.0*b.x)/3.0, (a.y + 2.0*b.y)/3.0)
ux = (t.x - s.x)*cos(pi/3.0) - (t.y - s.y)*sin(pi/3.0) + s.x
uy = (t.x - s.x)*sin(pi/3.0) + (t.y - s.y)*cos(pi/3.0) + s.y
u = coordinates(ux, uy)
koch(n-1, a, s)
print s.x, s.y
koch(n-1, s, u)
print u.x, u.y
koch(n-1, u, t)
print t.x, t.y
koch(n-1, t, b)
n = input()
p1 = coordinates(0.0, 0.0)
p2 = coordinates(100.0, 0.0)
print p1.x, p1.y
koch(n, p1, p2)
print p2.x, p2.y |
s365102605 | p02273 | u000228958 | 1452754211 | Python | Python | py | Runtime Error | 0 | 0 | 822 | import math
class Point:
def __init__(self, num_x, num_y):
self.x = num_x
self.y = num_y
def kock(n, p1, p2):
if n == 0:
return
s = Point((2 * p1.x + 1 * p2.x) / 3.0, (2 * p1.y + 1 * p2.y) / 3.0)
t = Point((1 * p1.x + 2 * p2.x) / 3.0, (1 * p1.y + 2 * p2.y) / 3.0)
u = Point(0, 0)
u.x = (t.x - s.x) * math.cos(math.pi / 3) - (t.y - s.y) * math.cos(math.pi / 3) + s.x
u.y = (t.x - s.x) * math.sin(math.pi / 3) - (t.y - s.y) * math.cos(math.pi / 3) + s.y
kock(n - 1, p1, s)
print "%f %f" % (s.x, s.y)
kock(n - 1, s, u)
print "%f %f" % (u.x, u.y)
kock(n - 1, u, t)
print "%f %f" % (t.x, t.y)
kock(n - 1, t, p2)
n = input()
p1 = Point(0, 0)
p2 = Point(100, 0)
print "%f %f" % (p1.x, p1.y)
kock(n, p1, p2)
print "%f %f" % (p2.x, p2.y |
s839010975 | p02273 | u724923896 | 1452840202 | Python | Python | py | Runtime Error | 10 | 6412 | 534 | import math
n = input()
px = 0
py = 0
qx = 100
qy = 0
def koch(n, px, py, qx, qy):
if n == 0:
return
s.x = (px*2+qx*1)/3
s.y = (py*2+qy*1)/3
t.x = (px*1+qx*2)/3
t.y = (py*1+qy*2)/3
u.x = (t.x-s.x)*math.cos(60) - (t.y-s.y)*math.sin(60) + s.x
u.y = (t.x-s.x)*math.sin(60) - (t.y-s.y)*math.cos(60) + s.y
koch(n-1, px, py, s.x, s.y)
print s.x, s.y
koch(n-1, s.x, s.y, u.x, s.y)
print u.x, u.y
koch(n-1, u.x, u.y, t.x, t.y)
print t.x, t.y
koch(n-1, t.x, t.u, qx, qy)
print px, py
koch(n, px, py, qx, qy)
print qx, qy |
s755394778 | p02273 | u724923896 | 1452840370 | Python | Python | py | Runtime Error | 10 | 6384 | 542 | import math
n = input()
px = 0
py = 0
qx = 100
qy = 0
def koch(n, px, py, qx, qy):
if n == 0:
return
s.x = (px*2+qx*1)/3
s.y = (py*2+qy*1)/3
t.x = (px*1+qx*2)/3
t.y = (py*1+qy*2)/3
u.x = (t.x-s.x)*math.cos(pi/3) - (t.y-s.y)*math.sin(pi/3) + s.x
u.y = (t.x-s.x)*math.sin(pi/3) - (t.y-s.y)*math.cos(pi/3) + s.y
koch(n-1, px, py, s.x, s.y)
print s.x, s.y
koch(n-1, s.x, s.y, u.x, s.y)
print u.x, u.y
koch(n-1, u.x, u.y, t.x, t.y)
print t.x, t.y
koch(n-1, t.x, t.u, qx, qy)
print px, py
koch(n, px, py, qx, qy)
print qx, qy |
s108330817 | p02273 | u724923896 | 1452840416 | Python | Python | py | Runtime Error | 10 | 6424 | 528 | import math
n = input()
px = 0
py = 0
qx = 100
qy = 0
def koch(n, px, py, qx, qy):
if n == 0:
return
s.x = (px*2+qx*1)/3
s.y = (py*2+qy*1)/3
t.x = (px*1+qx*2)/3
t.y = (py*1+qy*2)/3
u.x = (t.x-s.x)*cos(pi/3) - (t.y-s.y)*sin(pi/3) + s.x
u.y = (t.x-s.x)*sin(pi/3) - (t.y-s.y)*cos(pi/3) + s.y
koch(n-1, px, py, s.x, s.y)
print s.x, s.y
koch(n-1, s.x, s.y, u.x, s.y)
print u.x, u.y
koch(n-1, u.x, u.y, t.x, t.y)
print t.x, t.y
koch(n-1, t.x, t.u, qx, qy)
print px, py
koch(n, px, py, qx, qy)
print qx, qy |
s584469937 | p02273 | u724923896 | 1452840606 | Python | Python | py | Runtime Error | 10 | 6536 | 562 | import math
n = input()
px = float(0)
py = float(0)
qx = float(100)
qy = float(0)
def koch(n, px, py, qx, qy):
if n == 0:
return
s.x = (px*2+qx*1)/3
s.y = (py*2+qy*1)/3
t.x = (px*1+qx*2)/3
t.y = (py*1+qy*2)/3
u.x = (t.x-s.x)*cos(pi/3) - (t.y-s.y)*sin(pi/3) + s.x
u.y = (t.x-s.x)*sin(pi/3) - (t.y-s.y)*cos(pi/3) + s.y
koch(n-1, px, py, s.x, s.y)
print s.x, s.y
koch(n-1, s.x, s.y, u.x, s.y)
print u.x, u.y
koch(n-1, u.x, u.y, t.x, t.y)
print t.x, t.y
koch(n-1, t.x, t.u, qx, qy)
print px, py
koch(n, px, py, qx, qy)
print qx, qy |
s217132065 | p02273 | u724923896 | 1452840727 | Python | Python | py | Runtime Error | 10 | 6420 | 588 | import math
n = input()
px = float(0)
py = float(0)
qx = float(100)
qy = float(0)
def koch(n, px, py, qx, qy):
if n == 0:
return
s.x = (px*2+qx*1)/3
s.y = (py*2+qy*1)/3
t.x = (px*1+qx*2)/3
t.y = (py*1+qy*2)/3
u.x = (t.x-s.x)*math.cos(pi/3) - (t.y-s.y)*math.sin(pi/3) + s.x
u.y = (t.x-s.x)*math.sin(pi/3) + (t.y-s.y)*math.cos(pi/3) + s.y
koch(n-1, px, py, s.x, s.y)
print s.x, s.y
koch(n-1, s.x, s.y, u.x, s.y)
print u.x, u.y
koch(n-1, u.x, u.y, t.x, t.y)
print t.x, t.y
koch(n-1, t.x, t.u, qx, qy)
print px, py
koch(n, px, py, qx, qy)
print qx, qy |
s851975591 | p02273 | u724923896 | 1452840830 | Python | Python | py | Runtime Error | 10 | 6464 | 568 | import math
n = input()
px = float(0)
py = float(0)
qx = float(100)
qy = float(0)
def koch(n, px, py, qx, qy):
if n == 0:
return
s.x = (px*2+qx*1)/3
s.y = (py*2+qy*1)/3
t.x = (px*1+qx*2)/3
t.y = (py*1+qy*2)/3
u.x = (t.x-s.x)*cos(pi/3) - (t.y-s.y)*sin(pi/3) + s.x
u.y = (t.x-s.x)*sin(pi/3) + (t.y-s.y)*cos(pi/3) + s.y
koch(n-1, px, py, s.x, s.y)
print s.x, s.y
koch(n-1, s.x, s.y, u.x, u.y)
print u.x, u.y
koch(n-1, u.x, u.y, t.x, t.y)
print t.x, t.y
koch(n-1, t.x, t.u, qx, qy)
print px, py
koch(n, px, py, qx, qy)
print qx, qy |
s735746479 | p02273 | u724923896 | 1452840904 | Python | Python | py | Runtime Error | 10 | 6448 | 574 | import math
n = input()
px = float(0)
py = float(0)
qx = float(100)
qy = float(0)
def koch(n, px, py, qx, qy):
if n == 0:
return
s.x = (px*2+qx*1)/3
s.y = (py*2+qy*1)/3
t.x = (px*1+qx*2)/3
t.y = (py*1+qy*2)/3
u.x = (t.x-s.x)*cos(pi/3) - (t.y-s.y)*sin(pi/3) + s.x
u.y = (t.x-s.x)*sin(pi/3) + (t.y-s.y)*cos(pi/3) + s.y
koch(n-1, px, py, s.x, s.y)
print s.x, s.y
koch(n-1, s.x, s.y, u.x, u.y)
print u.x, u.y
koch(n-1, u.x, u.y, t.x, t.y)
print t.x, t.y
koch(n-1, t.x, t.y, qx, qy)
print px, py
koch(n, px, py, qx, qy)
print qx, qy |
s995970017 | p02273 | u724923896 | 1452841071 | Python | Python | py | Runtime Error | 10 | 6392 | 600 | import math
n = input()
px = float(0)
py = float(0)
qx = float(100)
qy = float(0)
def koch(n, px, py, qx, qy):
if n == 0:
return
s.x = (px*2+qx*1)/3
s.y = (py*2+qy*1)/3
t.x = (px*1+qx*2)/3
t.y = (py*1+qy*2)/3
u.x = (t.x-s.x)*math.cos(pi/3) - (t.y-s.y)*math.sin(pi/3) + s.x
u.y = (t.x-s.x)*math.sin(pi/3) + (t.y-s.y)*math.cos(pi/3) + s.y
koch(n-1, px, py, s.x, s.y)
print s.x, s.y
koch(n-1, s.x, s.y, u.x, u.y)
print u.x, u.y
koch(n-1, u.x, u.y, t.x, t.y)
print t.x, t.y
koch(n-1, t.x, t.y, qx, qy)
print px, py
koch(n, px, py, qx, qy)
print qx, qy |
s431867060 | p02273 | u724923896 | 1452841326 | Python | Python | py | Runtime Error | 0 | 6412 | 626 | import math
n = input()
px = float(0)
py = float(0)
qx = float(100)
qy = float(0)
def koch(n, px, py, qx, qy):
if n == 0:
return
s.x = (px*2+qx*1)/3
s.y = (py*2+qy*1)/3
t.x = (px*1+qx*2)/3
t.y = (py*1+qy*2)/3
u.x = (t.x-s.x)*math.cos(math.pi/3) - (t.y-s.y)*math.sin(math.pi/3) + s.x
u.y = (t.x-s.x)*math.sin(math.pi/3) + (t.y-s.y)*math.cos(math.pi/3) + s.y
koch(n-1, px, py, s.x, s.y)
print s.x, s.y
koch(n-1, s.x, s.y, u.x, u.y)
print u.x, u.y
koch(n-1, u.x, u.y, t.x, t.y)
print t.x, t.y
koch(n-1, t.x, t.y, qx, qy)
print px, py
koch(n, px, py, qx, qy)
print qx, qy |
s606302936 | p02273 | u724923896 | 1452841483 | Python | Python | py | Runtime Error | 10 | 6380 | 617 | import math
def koch(n, px, py, qx, qy):
if n == 0:
return
s.x = (px*2+qx)/3
s.y = (py*2+qy)/3
t.x = (px+qx*2)/3
t.y = (py+qy*2)/3
u.x = (t.x-s.x)*math.cos(math.pi/3) - (t.y-s.y)*math.sin(math.pi/3) + s.x
u.y = (t.x-s.x)*math.sin(math.pi/3) + (t.y-s.y)*math.cos(math.pi/3) + s.y
koch(n-1, px, py, s.x, s.y)
print s.x, s.y
koch(n-1, s.x, s.y, u.x, u.y)
print u.x, u.y
koch(n-1, u.x, u.y, t.x, t.y)
print t.x, t.y
koch(n-1, t.x, t.y, qx, qy)
n = input()
px = float(0)
py = float(0)
qx = float(100)
qy = float(0)
print px, py
koch(n, px, py, qx, qy)
print qx, qy |
s400318068 | p02273 | u724923896 | 1452843788 | Python | Python | py | Runtime Error | 0 | 0 | 631 | import math
def koch(n, p.x, p.y, q.x, q.y):
if n == 0:
return
s.x = (p.x*2+q.x)/3
s.y = (p.y*2+q.y)/3
t.x = (p.x+q.x*2)/3
t.y = (p.y+q.y*2)/3
u.x = (t.x-s.x)*math.cos(math.pi/3) - (t.y-s.y)*math.sin(math.pi/3) + s.x
u.y = (t.x-s.x)*math.sin(math.pi/3) + (t.y-s.y)*math.cos(math.pi/3) + s.y
koch(n-1, p.x, p.y, s.x, s.y)
print s.x, s.y
koch(n-1, s.x, s.y, u.x, u.y)
print u.x, u.y
koch(n-1, u.x, u.y, t.x, t.y)
print t.x, t.y
koch(n-1, t.x, t.y, q.x, q.y)
n = input()
p.x = 0.0
p.y = 0.0
q.x = 100.0
q.y = 0.0
print p.x, p.y
koch(n, p.x, p.y, q.x, q.y)
print q.x, q.y |
s836470803 | p02273 | u724923896 | 1452844213 | Python | Python | py | Runtime Error | 10 | 6384 | 607 | import math
def koch(n, h, i, j, k):
if n == 0:
return
s.x = (h*2+j)/3
s.y = (i*2+k)/3
t.x = (h+j*2)/3
t.y = (i+k*2)/3
u.x = (t.x-s.x)*math.cos(math.pi/3) - (t.y-s.y)*math.sin(math.pi/3) + s.x
u.y = (t.x-s.x)*math.sin(math.pi/3) + (t.y-s.y)*math.cos(math.pi/3) + s.y
koch(n-1, h, i, s.x, s.y)
print s.x, s.y
koch(n-1, s.x, s.y, u.x, u.y)
print u.x, u.y
koch(n-1, u.x, u.y, t.x, t.y)
print t.x, t.y
koch(n-1, t.x, t.y, j, k)
n = input()
px = float(0)
py = float(0)
qx = float(100)
qy = float(0)
print px, py
koch(n, px, py, qx, qy)
print qx, qy |
s595948319 | p02273 | u724923896 | 1452844835 | Python | Python | py | Runtime Error | 0 | 0 | 665 | import math
n = input()
p.x = float(0)
p.y = float(0)
q.x = float(100)
q.y = float(0)
def koch(n, p.x, p.y, q.x, q.y):
if n == 0:
return
s.x = (p.x*2+q.x*1)/3
s.y = (p.y*2+q.y*1)/3
t.x = (p.x*1+q.x*2)/3
t.y = (p.y*1+q.y*2)/3
u.x = (t.x-s.x)*math.cos(math.pi/3) - (t.y-s.y)*math.sin(math.pi/3) + s.x
u.y = (t.x-s.x)*math.sin(math.pi/3) + (t.y-s.y)*math.cos(math.pi/3) + s.y
koch(n-1, p.x, p.y, s.x, s.y)
print s.x, s.y
koch(n-1, s.x, s.y, u.x, u.y)
print u.x, u.y
koch(n-1, u.x, u.y, t.x, t.y)
print t.x, t.y
koch(n-1, t.x, t.y, q.x, q.y)
print p.x, p.y
koch(n, p.x, p.y, q.x, q.y)
print q.x, q.y |
s884503968 | p02273 | u724923896 | 1452924251 | Python | Python | py | Runtime Error | 10 | 6524 | 613 | import math
def koch(n, h, i, j, k):
if n == 0:
return
s.x = (h*2+j)/3
s.y = (i*2+k)/3
t.x = (h+j*2)/3
t.y = (i+k*2)/3
u.x = (t.x-s.x)*math.cos(math.pi/3) - (t.y-s.y)*math.sin(math.pi/3) + s.x
u.y = (t.x-s.x)*math.sin(math.pi/3) + (t.y-s.y)*math.cos(math.pi/3) + s.y
koch(n-1, h, i, s.x, s.y)
print s.x, s.y
koch(n-1, s.x, s.y, u.x, u.y)
print u.x, u.y
koch(n-1, u.x, u.y, t.x, t.y)
print t.x, t.y
koch(n-1, t.x, t.y, j, k)
n = input()
px = float(0)
py = float(0)
qx = float(100)
qy = float(0)
print px, py
koch(n, px, py, qx, qy)
print qx, qy |
s895532720 | p02273 | u724923896 | 1452924541 | Python | Python | py | Runtime Error | 10 | 6412 | 607 | import math
def koch(n, h, i, j, k):
if n == 0:
return
s.x = (h*2+j)/3
s.y = (i*2+k)/3
t.x = (h+j*2)/3
t.y = (i+k*2)/3
u.x = (t.x-s.x)*math.cos(math.pi/3) - (t.y-s.y)*math.sin(math.pi/3) + s.x
u.y = (t.x-s.x)*math.sin(math.pi/3) + (t.y-s.y)*math.cos(math.pi/3) + s.y
koch(n-1, h, i, s.x, s.y)
print s.x, s.y
koch(n-1, s.x, s.y, u.x, u.y)
print u.x, u.y
koch(n-1, u.x, u.y, t.x, t.y)
print t.x, t.y
koch(n-1, t.x, t.y, j, k)
n = input()
px = float(0)
py = float(0)
qx = float(100)
qy = float(0)
print px, py
koch(n, px, py, qx, qy)
print qx, qy |
s476763292 | p02273 | u724923896 | 1452924673 | Python | Python | py | Runtime Error | 10 | 6388 | 444 | import math
def koch(n, h, i, j, k):
if n == 0:
return
s.x = (h*2+j)/3
s.y = (i*2+k)/3
t.x = (h+j*2)/3
t.y = (i+k*2)/3
u.x = (t.x-s.x)*math.cos(math.pi/3) - (t.y-s.y)*math.sin(math.pi/3) + s.x
u.y = (t.x-s.x)*math.sin(math.pi/3) + (t.y-s.y)*math.cos(math.pi/3) + s.y
n = input()
px = float(0)
py = float(0)
qx = float(100)
qy = float(0)
print px, py
koch(n, px, py, qx, qy)
print qx, qy |
s102549056 | p02273 | u619765879 | 1452966475 | Python | Python | py | Runtime Error | 0 | 0 | 702 | def koch(n, a_x, a_y, b_x, b_y):
if n == 0:
return
th = math.pi*60.0/180.0
s_x = (2.0*a_x + 1.0*b_x)/3.0
s_y = (2.0*a_x + 1.0*b_x)/3.0
t_x = (1.0*a_x + 2.0*b_x)/3.0
t_y = (1.0*a_x + 2.0*b_x)/3.0
u_x = (t_x - s_x)*cos(th) + (t_y - s_y)*sin(th) + s_x
u_y = (t_x - s_x)*sin(th) + (t_y - s_y)*cos(th) + s_y
koch(n-1, a_x, a_y, s_x, s_y)
print '%.8f %8.f' % (s_x, s_y)
koch(n-1, s_x, s_y, u_x, u_y)
print '%.8f %8.f' % (u_x, u_y)
koch(n-1, u_x, u_y, t_x, t_y)
print '%.8f %8.f' % (t_x, t_y)
koch(n-1, t_x, t_y, b_x, b_y)
n = input()
a_x = 0.0
a_y = 0.0
b_x = 100.0
b_y = 0.0
print '%.8f %8.f' % (a_x, a_y)
koch(n-1, a_x, a_y, b_x, b_y)
print '%.8f %8.f' % (b_x, b_y) |
s213635075 | p02273 | u619765879 | 1452966874 | Python | Python | py | Runtime Error | 0 | 0 | 722 | def koch(n, a_x, a_y, b_x, b_y):
if n == 0:
return
th = math.pi*60.0/180.0
s_x = (2.0*a_x + 1.0*b_x)/3.0
s_y = (2.0*a_x + 1.0*b_x)/3.0
t_x = (1.0*a_x + 2.0*b_x)/3.0
t_y = (1.0*a_x + 2.0*b_x)/3.0
u_x = (t_x - s_x)*math.cos(th) + (t_y - s_y)*math.sin(th) + s_x
u_y = (t_x - s_x)*math.sin(th) + (t_y - s_y)*math.cos(th) + s_y
koch(n-1, a_x, a_y, s_x, s_y)
print '%.8f %8.f' % (s_x, s_y)
koch(n-1, s_x, s_y, u_x, u_y)
print '%.8f %8.f' % (u_x, u_y)
koch(n-1, u_x, u_y, t_x, t_y)
print '%.8f %8.f' % (t_x, t_y)
koch(n-1, t_x, t_y, b_x, b_y)
n = input()
a_x = 0.0
a_y = 0.0
b_x = 100.0
b_y = 0.0
print '%.8f %8.f' % (a_x, a_y)
koch(n-1, a_x, a_y, b_x, b_y)
print '%.8f %8.f' % (b_x, b_y) |
s247399661 | p02273 | u619765879 | 1452966983 | Python | Python | py | Runtime Error | 0 | 0 | 733 | def koch(n, a_x, a_y, b_x, b_y):
if n == 0:
return
th = math.pi*60.0/180.0
s_x = (2.0*a_x + 1.0*b_x)/3.0
s_y = (2.0*a_x + 1.0*b_x)/3.0
t_x = (1.0*a_x + 2.0*b_x)/3.0
t_y = (1.0*a_x + 2.0*b_x)/3.0
u_x = (t_x - s_x)*math.cos(th) + (t_y - s_y)*math.sin(th) + s_x
u_y = (t_x - s_x)*math.sin(th) + (t_y - s_y)*math.cos(th) + s_y
koch(n-1, a_x, a_y, s_x, s_y)
print '%.8f %8.f' % (s_x, s_y)
koch(n-1, s_x, s_y, u_x, u_y)
print '%.8f %8.f' % (u_x, u_y)
koch(n-1, u_x, u_y, t_x, t_y)
print '%.8f %8.f' % (t_x, t_y)
koch(n-1, t_x, t_y, b_x, b_y)
import math
n = input()
a_x = 0.0
a_y = 0.0
b_x = 100.0
b_y = 0.0
print '%.8f %8.f' % (a_x, a_y)
koch(n-1, a_x, a_y, b_x, b_y)
print '%.8f %8.f' % (b_x, b_y) |
s368570963 | p02273 | u619765879 | 1452967193 | Python | Python | py | Runtime Error | 10 | 6372 | 726 | def koch(n, a_x, a_y, b_x, b_y):
if n == 0:
return
th = math.pi*60.0/180.0
s_x = (2.0*a_x + 1.0*b_x)/3.0
s_y = (2.0*a_x + 1.0*b_x)/3.0
t_x = (1.0*a_x + 2.0*b_x)/3.0
t_y = (1.0*a_x + 2.0*b_x)/3.0
u_x = (t_x - s_x)*math.cos(th) + (t_y - s_y)*math.sin(th) + s_x
u_y = (t_x - s_x)*math.sin(th) + (t_y - s_y)*math.cos(th) + s_y
koch(n-1, a_x, a_y, s_x, s_y)
print '%.8f %8.f' % (s_x, s_y)
koch(n-1, s_x, s_y, u_x, u_y)
print '%.8f %8.f' % (u_x, u_y)
koch(n-1, u_x, u_y, t_x, t_y)
print '%.8f %8.f' % (t_x, t_y)
koch(n-1, t_x, t_y, b_x, b_y)
n = input()
a_x = 0.0
a_y = 0.0
b_x = 100.0
b_y = 0.0
print '%.8f %8.f' % (a_x, a_y)
koch(n, a_x, a_y, b_x, b_y)
print '%.8f %8.f' % (b_x, b_y) |
s408512372 | p02273 | u253463900 | 1453116789 | Python | Python3 | py | Runtime Error | 0 | 0 | 845 | import math
class point:
def __init__(self):
self.x = 0.0
self.y = 0.0
def koch(n,a,b):
if n == 0 :
return
rad = 1.0471975511965976 ???# 60 deg
s = point()
t = point()
u = point()
tmp = point()
s.x = (2 * a.x + b.x) / 3.0
s.y = (2 * a.y + b.y) / 3.0
t.x = (2 * b.x + a.x) / 3.0
t.y = (2 * b.y + a.y) / 3.0
tmp.x, tmp.y = s.x-t.x ,s.y-t.y
u.x = (tmp.x * math.cos(rad) + tmp.y * math.sin(rad)) + t.x
u.y = (-tmp.x * math.sin(rad) + tmp.y * math.cos(rad)) + t.y
koch(n-1, a, s)
print(s.x, s.y)
koch(n-1, s, u)
print(u.x, u.y)
koch(n-1, u, t)
print(t.x, t.y)
koch(n-1, t, b)
return
a = point()
b = point()
a.x, a.y = 0.0, 0.0
b.x, b.y = 100.0, 0.0
n = int(input())
print(a.x, a.y)
koch(n, a, b)
print(b.x, b.y) |
s138729087 | p02273 | u233232390 | 1453194745 | Python | Python | py | Runtime Error | 0 | 0 | 579 | import math
sin60 = math.sin(60*math.pi/180)
def koch(n,p1,p2):
if n==0:
return
s = [ ( 2*p1[0] + 1*p2[0] ) / 3 , ( 2*p1[1] + 1*p2[1]) / 3 ]
t = [ ( 1*p1[0] + 2*p2[0] ) / 3 , ( 1*p1[1] + 2*p2[1]) / 3 ]
u = [ ( t[0] - s[0] ) *0.5 - ( t[1] - s[1] )*sin60 + s[0],
( t[0] - s[0] )*sin60 + ( t[1] - s[1] )*0.5 + s[1] ]
koch(n-1,p1,s)
print s[0],s[1]
koch(n-1,s,u)
print u[0],u[1]
koch(n-1,u,t)
print t[0],t[1]
koch(n-1,t,p2)
n = raw_input()
p1 = (0,0)
p2 = (100,0)
print p1[0],p1[1]
koch(n,p1,p2)
print p2[0],p1[1] |
s529469311 | p02273 | u233232390 | 1453194769 | Python | Python | py | Runtime Error | 0 | 0 | 583 | import math
sin60 = math.sin(60*math.pi/180)
def koch(n,p1,p2):
if n==0:
return
s = [ ( 2*p1[0] + 1*p2[0] ) / 3. , ( 2*p1[1] + 1*p2[1]) / 3. ]
t = [ ( 1*p1[0] + 2*p2[0] ) / 3. , ( 1*p1[1] + 2*p2[1]) / 3. ]
u = [ ( t[0] - s[0] ) *0.5 - ( t[1] - s[1] )*sin60 + s[0],
( t[0] - s[0] )*sin60 + ( t[1] - s[1] )*0.5 + s[1] ]
koch(n-1,p1,s)
print s[0],s[1]
koch(n-1,s,u)
print u[0],u[1]
koch(n-1,u,t)
print t[0],t[1]
koch(n-1,t,p2)
n = raw_input()
p1 = (0,0)
p2 = (100,0)
print p1[0],p1[1]
koch(n,p1,p2)
print p2[0],p1[1] |
s887954923 | p02273 | u233232390 | 1453194813 | Python | Python | py | Runtime Error | 10 | 6452 | 503 | import math
def koch(n,p1,p2):
if n==0:
return
s = [(2*p1[0]+1*p2[0])/3, (2*p1[1]+1*p2[1])/3]
t = [(1*p1[0]+2*p2[0])/3, (1*p1[1]+2*p2[1])/3]
u = [(t[0]-s[0])*0.5 - (t[1]-s[1])*sin60+ s[0],
(t[0]-s[0])*sin60 + (t[1]-s[1])*0.5 + s[1]]
koch(n-1,p1,s)
print s[0],s[1]
koch(n-1,s,u)
print u[0],u[1]
koch(n-1,u,t)
print t[0],t[1]
koch(n-1,t,p2)
n = int(raw_input())
p1 = (0,0)
p2 = (100,0)
print p1[0],p1[1]
koch(n,p1,p2)
print p2[0],p1[1] |
s315282562 | p02273 | u393769849 | 1453202578 | Python | Python | py | Runtime Error | 10 | 6352 | 850 | n = int(raw_input())
p1_x = float(0)
p1_y = float(0)
p2_x = float(100)
p2_y = float(0)
def KC(i, n, x1, y1, x2, y2):
v = [0]*5
w = [0]*5
if i < n:
v[0] = x1
w[0] = y1
v[1] = (2*x1+x2)/3.0
w[1] = (2*y1+y2)/3.0
v[2] = (x1+2*x2)/3.0
w[2] = (y1+2*y2)/3.0
v[3] = (v[2] - v[1])*math.cos(math.pi/3) - (w[2] - w[1])*math.sin(math.pi/3) + v[1]
w[3] = (w[2] - w[1])*math.cos(math.pi/3) + (v[2] - v[1])*math.sin(math.pi/3) + w[1]
v[3] = x2
w[3] = y2
KC(i+1, n, v[0], w[0], v[1], w[1])
print v[1], w[1]
KC(i+1, n, v[1], w[1], v[3], w[3])
print v[3], w[3]
KC(i+1, n, v[3], w[3], v[2], w[2])
print v[2], w[2]
KC(i+1, n, v[2], w[2], v[4], w[4])
print p1_x, p1_y
KC(0, n, p1_x, p1_y, p2_x, p2_y)
print p2_x, p2_y |
s356769389 | p02273 | u424209323 | 1453204709 | Python | Python | py | Runtime Error | 0 | 0 | 613 | import math
def kock(n, x1, y1, x1, y2):
if n == 0:
return
angle = math.radians(60)
sx = (2*x1 + x2)/3
sy = (2*y1 + y2)/3
tx = (2*x2 + x1)/3
ty = (2*y2 + y1)/3
ux = (tx - sx)*math.cos(angle) - (ty - sy)*math.sin(angle) + sx
uy = (tx - sx)*math.sin(angle) + (ty - sy)*math.cos(angle) + sy
kock(n-1, x1, y1, sx, sy)
print sx, sy
kock(n-1, sx, sy, ux, uy)
print ux, uy
kock(n-1, ux, uy, tx, ty)
print tx, ty
kock(n-1, tx, ty, x2, y2)
n = input()
p1x = 0.
p1y = 0.
p2x = 100.
p2y = 0.
print p1x, p1y
kock(n, p1x, p1y, p2x, p2y)
print p2x, p2y |
s644551761 | p02273 | u424209323 | 1453204733 | Python | Python | py | Runtime Error | 0 | 0 | 613 | import math
def kock(n, x1, y1, x1, y2):
if n == 0:
return
angle = math.radians(60)
sx = (2*x1 + x2)/3
sy = (2*y1 + y2)/3
tx = (2*x2 + x1)/3
ty = (2*y2 + y1)/3
ux = (tx - sx)*math.cos(angle) - (ty - sy)*math.sin(angle) + sx
uy = (tx - sx)*math.sin(angle) + (ty - sy)*math.cos(angle) + sy
kock(n-1, x1, y1, sx, sy)
print sx, sy
kock(n-1, sx, sy, ux, uy)
print ux, uy
kock(n-1, ux, uy, tx, ty)
print tx, ty
kock(n-1, tx, ty, x2, y2)
n = input()
p1x = 0.
p1y = 0.
p2x = 100.
p2y = 0.
print p1x, p1y
kock(n, p1x, p1y, p2x, p2y)
print p2x, p2y |
s510878815 | p02273 | u563876281 | 1453206969 | Python | Python | py | Runtime Error | 0 | 0 | 571 | n = int(raw_input())
p1 = complex(0,0)
p2 = complex(100,0)
for e in koch(p1,p2,n):
print e.real,e.imagimport math, cmath
def koch(p1, p2, n):
if n == 0:
return [p1, p2]
rad60 = math.pi/3
v1 = (p2 - p1)/3
v2 = cmath.rect(abs(v1), cmath.phase(v1)+rad60)
q1 = p1 + v1
q2 = q1 + v2
q3 = q1 + v1
if n == 1:
return [p1,q1,q2,q3,p2]
else:
x1 = koch(p1,q1,n-1)[:-1]
x2 = koch(q1,q2,n-1)[:-1]
x3 = koch(q2,q3,n-1)[:-1]
x4 = koch(q3,p2,n-1)
x = x1 + x2 + x3 + x4
return x |
s090212610 | p02273 | u563876281 | 1453207009 | Python | Python | py | Runtime Error | 0 | 0 | 583 | import math
n = int(raw_input())
p1 = complex(0,0)
p2 = complex(100,0)
for e in koch(p1,p2,n):
print e.real,e.imagimport math, cmath
def koch(p1, p2, n):
if n == 0:
return [p1, p2]
rad60 = math.pi/3
v1 = (p2 - p1)/3
v2 = cmath.rect(abs(v1), cmath.phase(v1)+rad60)
q1 = p1 + v1
q2 = q1 + v2
q3 = q1 + v1
if n == 1:
return [p1,q1,q2,q3,p2]
else:
x1 = koch(p1,q1,n-1)[:-1]
x2 = koch(q1,q2,n-1)[:-1]
x3 = koch(q2,q3,n-1)[:-1]
x4 = koch(q3,p2,n-1)
x = x1 + x2 + x3 + x4
return x |
s928610625 | p02273 | u563876281 | 1453207068 | Python | Python | py | Runtime Error | 0 | 0 | 645 | import math, cmath
n = int(raw_input())
p1 = complex(0,0)
p2 = complex(100,0)
for e in koch(p1,p2,n):
print e.real,e.imag
def koch(p1, p2, n):
if n == 0:
return [p1, p2]
rad60 = math.pi/3
v1 = (p2 - p1)/3
v2 = cmath.rect(abs(v1), cmath.phase(v1)+rad60)
q1 = p1 + v1
q2 = q1 + v2
q3 = q1 + v1
if n == 1:
return [p1,q1,q2,q3,p2]
else:
x1 = koch(p1,q1,n-1)[:-1]
x2 = koch(q1,q2,n-1)[:-1]
x3 = koch(q2,q3,n-1)[:-1]
x4 = koch(q3,p2,n-1)
x = x1 + x2 + x3 + x4
return x
x4 = koch(q3,p2,n-1)
x = x1 + x2 + x3 + x4
return x |
s050397794 | p02273 | u563876281 | 1453207235 | Python | Python | py | Runtime Error | 0 | 0 | 574 | import math, cmath
def koch(v1, v2, n):
if n == 0:
return [v1, v2]
rad60 = math.pi/3
u1 = (v2 - v1)/3
u2 = cmath.rect(abs(u1), cmath.phase(u1)+rad60)
q1 = v1 + u1
q2 = q1 + u2
q3 = q1 + u1
if n == 1:
return [v1,q1,q2,q3,v2]
else:
x1 = koch(v1,q1,n-1)[:-1]
x2 = koch(q1,q2,n-1)[:-1]
x3 = koch(q2,q3,n-1)[:-1]
x4 = koch(q3,v2,n-1)
x = x1 + x2 + x3 + x4
return x
n = int(raw_input())
v1 = complex(0,0)
v2 = complex(100,0)
for e in koch(p1,p2,n):
print e.real,e.imag |
s627813065 | p02273 | u047737909 | 1453208180 | Python | Python | py | Runtime Error | 0 | 0 | 886 | import math
x1 = 0
y1 = 0
x2 = 100
y2 = 0
def koch curve(i, n, x1, y1, x2, y2):
x = [0] * 5
y = [0] * 5
if i < n:
x[0] = x1
y[0] = y1
x[1] = (2 * x1 + x2) / 3.0
y[1] = (2 * y1 + y2) / 3.0
x[2] = (x1 + 2 * x2) / 3.0
y[2] = (y1 + 2 * y2) / 3.0
x[3] = (x[2] - x[1]) * math.cos(math.pi/3) - (x[2] - x[1]) * math.sin(math.pi/3) + y[1]
y[3] = (y[2] - y[1]) * math.cos(math.pi/3) + (y[2] - y[1]) * math.sin(math.pi/3) + x[1]
x[4] = x2
y[4] = y2
koch curve(i+1, n, x[0], y[0], x[1], y[1])
print x[1], y[1]
koch curve(i+1, n, x[1], y[1], x[3], y[3])
print x[3], y[3]
koch curve(i+1, n, x[3], y[3], x[2], y[2])
print x[2], y[2]
koch curve(i+1, n, x[2], y[2], x[4], y[4])
n = input()
print x1 y1
koch curve(0, n, x1, y1, x2,y2)
print x2, y2 |
s412235126 | p02273 | u047737909 | 1453208385 | Python | Python | py | Runtime Error | 0 | 0 | 887 |
import math
x1 = 0
y1 = 0
x2 = 100
y2 = 0
def koch curve(i, n, x1, y1, x2, y2):
x = [0] * 5
y = [0] * 5
if i < n:
x[0] = x1
y[0] = y1
x[1] = (2 * x1 + x2) / 3.0
y[1] = (2 * y1 + y2) / 3.0
x[2] = (x1 + 2 * x2) / 3.0
y[2] = (y1 + 2 * y2) / 3.0
x[3] = (x[2] - x[1]) * math.cos(math.pi/3) - (x[2] - x[1]) * math.sin(math.pi/3) + x[1]
y[3] = (y[2] - y[1]) * math.cos(math.pi/3) + (y[2] - y[1]) * math.sin(math.pi/3) + y[1]
x[4] = x2
y[4] = y2
koch_curve(i+1, n, x[0], y[0], x[1], y[1])
print x[1], y[1]
koch_curve(i+1, n, x[1], y[1], x[3], y[3])
print x[3], y[3]
koch_curve(i+1, n, x[3], y[3], x[2], y[2])
print x[2], y[2]
koch_curve(i+1, n, x[2], y[2], x[4], y[4])
n = input()
print x1 y1
koch_curve(0, n, x1, y1, x2,y2)
print x2, y2 |
s042003325 | p02273 | u047737909 | 1453208452 | Python | Python | py | Runtime Error | 0 | 0 | 837 |
ef koch_curve(i, n, x1, y1, x2, y2):
x = [0] * 5
y = [0] * 5
if i < n:
x[0] = x1
y[0] = y1
x[1] = (2 * x1 + x2) / 3.0
y[1] = (2 * y1 + y2) / 3.0
x[2] = (x1 + 2 * x2) / 3.0
y[2] = (y1 + 2 * y2) / 3.0
x[3] = (x[2] - x[1]) * math.cos(math.pi/3) - (x[2] - x[1]) * math.sin(math.pi/3) + x[1]
y[3] = (y[2] - y[1]) * math.cos(math.pi/3) + (y[2] - y[1]) * math.sin(math.pi/3) + y[1]
x[4] = x2
y[4] = y2
koch_curve(i+1, n, x[0], y[0], x[1], y[1])
print x[1], y[1]
koch_curve(i+1, n, x[1], y[1], x[3], y[3])
print x[3], y[3]
koch_curve(i+1, n, x[3], y[3], x[2], y[2])
print x[2], y[2]
koch_curve(i+1, n, x[2], y[2], x[4], y[4])
n = input()
print x1 y1
koch_curve(0, n, x1, y1, x2,y2)
print x2, y2 |
s778357397 | p02273 | u047737909 | 1453208516 | Python | Python | py | Runtime Error | 0 | 0 | 886 | import math
x1 = 0
y1 = 0
x2 = 100
y2 = 0
def koch_curve(i, n, x1, y1, x2, y2):
x = [0] * 5
y = [0] * 5
if i < n:
x[0] = x1
y[0] = y1
x[1] = (2 * x1 + x2) / 3.0
y[1] = (2 * y1 + y2) / 3.0
x[2] = (x1 + 2 * x2) / 3.0
y[2] = (y1 + 2 * y2) / 3.0
x[3] = (x[2] - x[1]) * math.cos(math.pi/3) - (x[2] - x[1]) * math.sin(math.pi/3) + x[1]
y[3] = (y[2] - y[1]) * math.cos(math.pi/3) + (y[2] - y[1]) * math.sin(math.pi/3) + y[1]
x[4] = x2
y[4] = y2
koch_curve(i+1, n, x[0], y[0], x[1], y[1])
print x[1], y[1]
koch_curve(i+1, n, x[1], y[1], x[3], y[3])
print x[3], y[3]
koch_curve(i+1, n, x[3], y[3], x[2], y[2])
print x[2], y[2]
koch_curve(i+1, n, x[2], y[2], x[4], y[4])
n = input()
print x1 y1
koch_curve(0, n, x1, y1, x2,y2)
print x2, y2 |
s572999840 | p02273 | u047737909 | 1453208638 | Python | Python | py | Runtime Error | 0 | 0 | 886 | import math
x1 = 0
y1 = 0
x2 = 100
y2 = 0
def koch_curve(i, n, x1, y1, x2, y2):
x = [0] * 5
y = [0] * 5
if i < n:
x[0] = x1
y[0] = y1
x[1] = (2 * x1 + x2) / 3.0
y[1] = (2 * y1 + y2) / 3.0
x[2] = (x1 + 2 * x2) / 3.0
y[2] = (y1 + 2 * y2) / 3.0
x[3] = (x[2] - x[1]) * math.cos(math.pi/3) - (x[2] - x[1]) * math.sin(math.pi/3) + x[1]
y[3] = (y[2] - y[1]) * math.cos(math.pi/3) + (y[2] - y[1]) * math.sin(math.pi/3) + y[1]
x[4] = x2
y[4] = y2
koch_curve(i+1, n, x[0], y[0], x[1], y[1])
print x[1], y[1]
koch_curve(i+1, n, x[1], y[1], x[3], y[3])
print x[3], y[3]
koch_curve(i+1, n, x[3], y[3], x[2], y[2])
print x[2], y[2]
koch_curve(i+1, n, x[2], y[2], x[4], y[4])
n = input()
print x1 y1
koch_curve(0, n, x1, y1, x2,y2)
print x2, y2 |
s721207655 | p02273 | u536494052 | 1453215278 | Python | Python | py | Runtime Error | 0 | 0 | 1050 | 03 sec 6668 KB 36 lines 878 bytes 2016-01-16 19:46
?
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
import math
n = input()
p1_x = float(0)
p1_y = float(0)
p2_x = float(100)
p2_y = float(0)
def kock(i, n, x1, y1, x2, y2):
a = [0,0,0,0,0]
b = [0,0,0,0,0]
if i < n:
a[0] = x1
b[0] = y1
a[1] = (2*x1+x2)/3.0
b[1] = (2*y1+y2)/3.0
a[2] = (x1+2*x2)/3.0
b[2] = (y1+2*y2)/3.0
a[3] = (a[2] - a[1])*math.cos(math.pi/3) - (b[2] - b[1])*math.sin(math.pi/3) + a[1]
b[3] = (b[2] - b[1])*math.cos(math.pi/3) + (a[2] - a[1])*math.sin(math.pi/3) + b[1]
a[4] = x2
b[4] = y2
kock(i+1, n, a[0], b[0], a[1], b[1])
print a[1], b[1]
kock(i+1, n, a[1], b[1], a[3], b[3])
print a[3], b[3]
kock(i+1, n, a[3], b[3], a[2], b[2])
print a[2], b[2]
kock(i+1, n, a[2], b[2], a[4], b[4])
print p1_x, p1_y
kock(0, n, p1_x, p1_y, p2_x, p2_y)
print p2_x, p2_y
|
s850112301 | p02273 | u536494052 | 1453215362 | Python | Python | py | Runtime Error | 0 | 0 | 1050 | 03 sec 6668 KB 36 lines 878 bytes 2016-01-16 19:46
?
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
import math
n = input()
p1_x = float(0)
p1_y = float(0)
p2_x = float(100)
p2_y = float(0)
def kock(i, n, x1, y1, x2, y2):
a = [0,0,0,0,0]
b = [0,0,0,0,0]
if i < n:
a[0] = x1
b[0] = y1
a[1] = (2*x1+x2)/3.0
b[1] = (2*y1+y2)/3.0
a[2] = (x1+2*x2)/3.0
b[2] = (y1+2*y2)/3.0
a[3] = (a[2] - a[1])*math.cos(math.pi/3) - (b[2] - b[1])*math.sin(math.pi/3) + a[1]
b[3] = (b[2] - b[1])*math.cos(math.pi/3) + (a[2] - a[1])*math.sin(math.pi/3) + b[1]
a[4] = x2
b[4] = y2
kock(i+1, n, a[0], b[0], a[1], b[1])
print a[1], b[1]
kock(i+1, n, a[1], b[1], a[3], b[3])
print a[3], b[3]
kock(i+1, n, a[3], b[3], a[2], b[2])
print a[2], b[2]
kock(i+1, n, a[2], b[2], a[4], b[4])
print p1_x, p1_y
kock(0, n, p1_x, p1_y, p2_x, p2_y)
print p2_x, p2_y
|
s114137053 | p02273 | u824216249 | 1453215450 | Python | Python | py | Runtime Error | 0 | 0 | 629 | import math
def koch(n, x1, y1, x2, y2):
if n == 0:
return
angle = math.radians(60)
sx = (2*x1 + x2)/3
sy = (2*y1 + y2)/3
tx = (2*x2 + x1)/3
ty = (2*y2 + y1)/3
ux = (tx - sx)*math.cos(angle) - (ty - sy)*math.sin(angle) + sx
uy = (tx - sx)*math.sin(angle) + (ty - sy)*math.cos(angle) + sy
koch(n-1, x1, y1, sx, sy)
print sx, sy
koch(n-1, sx, sy, ux, uy)
print ux, uy
koch(n-1, ux, uy, tx, ty)
print tx, ty
koch(n-1, tx, ty, x2, y2)
n = input()
p1x = 0.0
p1y = 0.0
p2x = 100.0
p2y = 0.0
print p1x, p1y
kock(n, p1x, p1y, p2x, p2y)
print p2x, p2y |
s352038478 | p02273 | u177808190 | 1453217138 | Python | Python | py | Runtime Error | 0 | 0 | 692 | degree = math.pi / 3
def print_point(point):
print "%f %f"
def koch(depth, p1, p2):
if depth == 0:
return
s = ((2 * p1[0] + p2[0]) / 3, (2 * p1[1] + p2[1]) / 3)
t = ((p1[0] + 2 * p2[0]) / 3, (p1[1] + 2 * p2[1]) / 3)
u = ((t[0] - s[0]) * math.cos(degree) - (t[1] - s[1]) * math.sin(degree) + s[0],
(t[0] - s[0]) * math.sin(degree) + (t[1] - s[1]) * math.cos(degree) + s[1])
depth -= 1
koch(depth, p1, s)
print_point(s)
koch(depth, s, u)
print_point(u)
koch(depth, u, t)
print_point(t)
koch(depth, t, p2)
n = int(raw_input())
start = (0.0, 0.0)
end = (100.0, 0.0)
print_point(start)
koch(n, start, end)
print_point(end) |
s147468535 | p02273 | u177808190 | 1453249039 | Python | Python | py | Runtime Error | 0 | 0 | 823 | import math
n = int(raw_input())
degree = math.pi / 3
??????????
def print_point(point):
????????print "%f %f" % (point[0], point[1])
??????????
def koch(depth, p1, p2):
????????if depth == 0:
????????????????return
????????s = ((2 * p1[0] + p2[0]) / 3, (2 * p1[1] + p2[1]) / 3)
????????t = ((p1[0] + 2 * p2[0]) / 3, (p1[1] + 2 * p2[1]) / 3)
????????u = ((t[0] - s[0]) * math.cos(degree) - (t[1] - s[1]) * math.sin(degree) + s[0],
??????????????????(t[0] - s[0]) * math.sin(degree) + (t[1] - s[1]) * math.cos(degree) + s[1])
????????depth -= 1
????????koch(depth, p1, s)
????????print_point(s)
????????koch(depth, s, u)
????????print_point(u)
????????koch(depth, u, t)
????????print_point(t)
????????koch(depth, t, p2)
??????????
start = (0.0, 0.0)
end = (100.0, 0.0)
print_point(start)
koch(n, start, end)
print_point(end) |
s800214734 | p02273 | u682357930 | 1453258208 | Python | Python | py | Runtime Error | 0 | 0 | 585 | import math
n = input()
def koch(n, p1_x, p2_x, p1_y, p2_y):
if n == 0:
return
%p1, p2 ?????? s, t, u ????¨????
s_x = (2*p1_x + p2_x) / 3
s_y = (2*p1_y + p2_y) / 3
t_x = (p1_x + 2*p2_x) / 3
t_y = (p1_y + 2*p2_y) / 3
u_x = (t_x - s_x)/2 - (t_y - s_y) * sqrt(3)/2 + s_x
u_y = (t_x - s_x) * sqrt(3)/2 + (t_y - s_y)/2 + s_y
koch(n-1, p1_x, s_x, p1_y, s_y)
print s_x, s_y
koch(n-1, s_x, u_x, s_y, u_y)
print u_x, u_y
koch(n-1, u_x, t_x, u_y, t_y)
print t_x, t_y
koch(n-1, t_x, p2_x, t_y, p2_y)
print 0.0, 0.0
koch(n, 0, 100, 0, 0)
print 100.0, 0.0 |
s820803459 | p02273 | u682357930 | 1453258283 | Python | Python | py | Runtime Error | 0 | 0 | 634 | import math
n = input()
def koch(n, p1_x, p2_x, p1_y, p2_y):
if n == 0:
return
%p1, p2 ?????? s, t, u ????¨????
s_x = (2*p1_x + p2_x) / 3
s_y = (2*p1_y + p2_y) / 3
t_x = (p1_x + 2*p2_x) / 3
t_y = (p1_y + 2*p2_y) / 3
u_x = (t_x - s_x)/2 - (t_y - s_y) * sqrt(3)/2 + s_x
u_y = (t_x - s_x) * sqrt(3)/2 + (t_y - s_y)/2 + s_y
koch(n-1, p1_x, s_x, p1_y, s_y)
print s_x, s_y
koch(n-1, s_x, u_x, s_y, u_y)
print u_x, u_y
koch(n-1, u_x, t_x, u_y, t_y)
print t_x, t_y
koch(n-1, t_x, p2_x, t_y, p2_y)
p1_x = 0.0
p1_y = 0.0
p2_x = 100.0
p2_y = 0.0
print p1_x, p1_y
koch(n, 0, 100, 0, 0)
print p2_x, p2_y |
s772087317 | p02273 | u682357930 | 1453258310 | Python | Python | py | Runtime Error | 10 | 6412 | 595 | import math
n = input()
def koch(n, p1_x, p2_x, p1_y, p2_y):
if n == 0:
return
s_x = (2*p1_x + p2_x) / 3
s_y = (2*p1_y + p2_y) / 3
t_x = (p1_x + 2*p2_x) / 3
t_y = (p1_y + 2*p2_y) / 3
u_x = (t_x - s_x)/2 - (t_y - s_y) * sqrt(3)/2 + s_x
u_y = (t_x - s_x) * sqrt(3)/2 + (t_y - s_y)/2 + s_y
koch(n-1, p1_x, s_x, p1_y, s_y)
print s_x, s_y
koch(n-1, s_x, u_x, s_y, u_y)
print u_x, u_y
koch(n-1, u_x, t_x, u_y, t_y)
print t_x, t_y
koch(n-1, t_x, p2_x, t_y, p2_y)
p1_x = 0.0
p1_y = 0.0
p2_x = 100.0
p2_y = 0.0
print p1_x, p1_y
koch(n, 0, 100, 0, 0)
print p2_x, p2_y |
s630453693 | p02273 | u334643297 | 1453258370 | Python | Python | py | Runtime Error | 0 | 0 | 409 | import math
from numpy import array
def koch(n, a, b):
print '%.8f %.8f' % (a[0], a[1])
if(n == 0):
return
x = (a*2 + b) / 3
y = (a - b) * array([math.cos(math.pi/3), -math.sin(math.pi/3)],[math.sin(math.pi/3), math.cos(math.pi/3)]) + x
z = (a + b*2) / 3
koch(n-1, a, x)
koch(n-1, x, y)
koch(n-1, y, z)
koch(n-1, z, b)
n = input()
p1 = array([0.0, 0.0])
p2 = array([100.0, 0.0])
koch(n, p1, p2) |
s875097209 | p02273 | u682357930 | 1453258393 | Python | Python | py | Runtime Error | 10 | 6456 | 595 | import math
n = input()
def koch(n, p1_x, p2_x, p1_y, p2_y):
if n == 0:
return
s_x = (2*p1_x + p2_x) / 3
s_y = (2*p1_y + p2_y) / 3
t_x = (p1_x + 2*p2_x) / 3
t_y = (p1_y + 2*p2_y) / 3
u_x = (t_x - s_x)/2 - (t_y - s_y) * sqrt(3)/2 + s_x
u_y = (t_x - s_x) * sqrt(3)/2 + (t_y - s_y)/2 + s_y
koch(n-1, p1_x, s_x, p1_y, s_y)
print s_x, s_y
koch(n-1, s_x, u_x, s_y, u_y)
print u_x, u_y
koch(n-1, u_x, t_x, u_y, t_y)
print t_x, t_y
koch(n-1, t_x, p2_x, t_y, p2_y)
p1_x = 0.0
p1_y = 0.0
p2_x = 100.0
p2_y = 0.0
print p1_x, p1_y
koch(n, 0, 100, 0, 0)
print p2_x, p2_y |
s665945407 | p02273 | u682357930 | 1453258709 | Python | Python | py | Runtime Error | 10 | 6524 | 595 | import math
n = input()
def koch(n, p1_x, p2_x, p1_y, p2_y):
if n == 0:
return
s_x = (2*p1_x + p2_x) / 3
s_y = (2*p1_y + p2_y) / 3
t_x = (p1_x + 2*p2_x) / 3
t_y = (p1_y + 2*p2_y) / 3
u_x = (t_x - s_x)/2 - (t_y - s_y) * sqrt(3)/2 + s_x
u_y = (t_x - s_x) * sqrt(3)/2 + (t_y - s_y)/2 + s_y
koch(n-1, p1_x, s_x, p1_y, s_y)
print s_x, s_y
koch(n-1, s_x, u_x, s_y, u_y)
print u_x, u_y
koch(n-1, u_x, t_x, u_y, t_y)
print t_x, t_y
koch(n-1, t_x, p2_x, t_y, p2_y)
p1_x = 0.0
p1_y = 0.0
p2_x = 100.0
p2_y = 0.0
print p1_x, p1_y
koch(n, 0, 100, 0, 0)
print p2_x, p2_y |
s968913197 | p02273 | u963402991 | 1459471031 | Python | Python3 | py | Runtime Error | 20 | 7756 | 820 | import math
n = int(input())
theta = math.pi / 3
p1 = [0, 0]
p2 = [100, 0]
def kock(d, p1, p2):
if d == 0:
return
sx = (p1[0] + 2 * p2[0]) / 3
tx = (2 * p1[0] + p2[0]) / 3
sy = (p1[1] + 2 * p2[1]) / 3
ty = (2 * p1[1] + p2[1]) / 3
s = [sx, sy]
t = [tx, ty]
ux = (t[0] - s[0]) * math.cos(theta) + (t[1] - s[1]) * math.sin(theta) + sx
uy = (t[1] - s[1]) * math.cos(theta) - (t[0] - s[0]) * math.sin(theta) + sy
u = [ux, uy]
kock(n - 1, p1, s)
print("{0} {1}".format(s[0], s[1], '.8f'))
kock(n - 1, s, u)
print("{0} {1}".format(u[0], u[1], '.8f'))
kock(n -1 ,u, t)
print("{0} {1}".format(t[0], t[1], '.8f'))
kock(n - 1, t, p2)
if __name__ == '__main__':
print("0.0000000 0.0000000")
kock(n, p1, p2)
print("100.0000000 0.0000000") |
s856123681 | p02273 | u086566114 | 1493173665 | Python | Python3 | py | Runtime Error | 0 | 0 | 2048 | # coding=utf-8
import math
def divide_segment(left, right):
"""divide segment
Args:
left: left edge coordinate
right: right edge coordinate
Returns:
divided points
"""
delta_x_quarter = (right[0] - left[0]) / 3.0
delta_y_quarter = (right[1] - left[1]) / 3.0
delta_x_quarter_rotated = (delta_x_quarter - math.sqrt(3) * delta_y_quarter) / 2.0
delta_y_quarter_rotated = (math.sqrt(3) * delta_x_quarter + delta_y_quarter) / 2.0
s = [left[0] + delta_x_quarter, left[1] + delta_y_quarter]
t = [left[0] + delta_x_quarter * 2.0, left[1] + delta_y_quarter * 2.0]
u = [s[0] + delta_x_quarter_rotated, s[1] + delta_y_quarter_rotated]
return s, t, u
def make_coch_curve(depth, left, right):
"""make coch curve with depth iteration_number between point left, right
each vertices positions are printed
Args:
depth: depth
left: left edge point
right: right edge point
Returns:
None
"""
print("{0:2.8f} {1:2.8f}".format(left[0], left[1]))
make_coch_curve_recursively(depth, left, right)
def make_coch_curve_recursively(depth, left, right):
"""recursion part of coch curve
Args:
depth: depth
left: left edge coordinate
right: right edge coordinate
Returns:
None
"""
# get coordinate of divided points
s, t, u = divide_segment(left, right)
if depth == 1:
print("{0:2.8f} {1:2.8f}".format(s[0], s[1]))
print("{0:2.8f} {1:2.8f}".format(u[0], u[1]))
print("{0:2.8f} {1:2.8f}".format(t[0], t[1]))
print("{0:2.8f} {1:2.8f}".format(right[0], right[1]))
else:
make_coch_curve_recursively(depth - 1, left, s)
make_coch_curve_recursively(depth - 1, s, u)
make_coch_curve_recursively(depth - 1, u, t)
make_coch_curve_recursively(depth - 1, t, right)
def main():
depth = int(input().strip())
make_coch_curve(depth, left=[0.0, 0.0], right=[100.0, 0.0])
if __name__ == '__main__':
main() |
s196323602 | p02273 | u003309334 | 1495817495 | Python | Python3 | py | Runtime Error | 0 | 0 | 544 | import numpy as np
import math
def kochCurve(p1, p2, n):
if n == 0:
print(p2[0], p2[1])
return
v = (p2 - p1)/3
s = p1 + v
t = s + v
theta = math.atan2(v[1], v[0])
a = np.linalg.norm(t - s)
h = 3**(1/2)*a/2
u = s + (t - s)/2 + np.array([h*math.sin(theta), h*math.cos(theta)])
# print(n, p1, s, u, t, p2)
n -= 1
kochCurve(p1, s, n)
kochCurve(s, u, n)
kochCurve(u, t, n)
kochCurve(t, p2, n)
if __name__ == "__main__":
n = int(input())
print([0, 0])
kochCurve(np.array([0, 0]), np.array([100, 0]), n) |
s416917819 | p02273 | u003309334 | 1495817600 | Python | Python3 | py | Runtime Error | 0 | 0 | 542 | import numpy as np
import math
def kochCurve(p1, p2, n):
if n == 0:
print(p2[0], p2[1])
return
v = (p2 - p1)/3
s = p1 + v
t = s + v
theta = math.atan2(v[1], v[0])
a = np.linalg.norm(t - s)
h = 3**(1/2)*a/2
u = s + (t - s)/2 + np.array([h*math.sin(theta), h*math.cos(theta)])
# print(n, p1, s, u, t, p2)
n -= 1
kochCurve(p1, s, n)
kochCurve(s, u, n)
kochCurve(u, t, n)
kochCurve(t, p2, n)
if __name__ == "__main__":
n = int(input())
print(0, 0)
kochCurve(np.array([0, 0]), np.array([100, 0]), n) |
s419505599 | p02273 | u918276501 | 1499294057 | Python | Python3 | py | Runtime Error | 0 | 0 | 567 | import numpy as np
def koch_divide(p,q):
v = q-p
r = np.array([[0.866, 0.5],[-0.5, 0.866]])
s = p + v/3
t = q - v/3
u = p + np.dot(v,r)/np.sqrt(3)
return [s,u,t,q]
def koch_curve(previous):
vertices = [previous[0]]
for p,q in zip(previous[:-1], previous[1:]):
vertices.append(koch_divide(p,q))
return vertices
if __name__=='__main__':
p_q = np.array([[0.0, 0.0], [100.0, 0.0]])
n = int(input())
for _ in range(n):
p_q = koch_curve(p_q)
for vertex in p_q:
print(" ".join(map(str, vertex))) |
s565769526 | p02273 | u918276501 | 1499294365 | Python | Python3 | py | Runtime Error | 0 | 0 | 581 | import numpy as np
def koch_divide(p,q):
v = q-p
r = np.array([[np.sqrt(3)/2, 0.5],[-0.5, np.sqrt(3)/2]])
s = p + v/3
t = q - v/3
u = p + np.dot(v,r)/np.sqrt(3)
return [s,u,t,q]
def koch_curve(previous):
vertices = [previous[0]]
for p,q in zip(previous[:-1], previous[1:]):
vertices.extend(koch_divide(p,q))
return vertices
if __name__=='__main__':
p_q = np.array([[0.0, 0.0], [100.0, 0.0]])
n = int(input())
for _ in range(n):
p_q = koch_curve(p_q)
for vertex in p_q:
print(" ".join(map(str, vertex))) |
s974037051 | p02273 | u918276501 | 1499295901 | Python | Python3 | py | Runtime Error | 0 | 0 | 601 | import numpy as np
def koch_divide(p,q):
v = q-p
r = np.array([[np.sqrt(3)/2, 0.5],[-0.5, np.sqrt(3)/2]])
s = p + v/3
t = q - v/3
u = p + np.dot(v,r)/np.sqrt(3)
return [s,u,t,q]
def koch_curve(previous):
vertices = [previous[0]]
for p,q in zip(previous[:-1], previous[1:]):
vertices.extend(koch_divide(p,q))
return vertices
if __name__=='__main__':
p_q = np.array([[0.0, 0.0], [100.0, 0.0]])
n = int(input())
for _ in range(n):
p_q = koch_curve(p_q)
for vertex in p_q:
print(" ".join(np.vectorize("%.8f".__mod__)(vertex))) |
s642131212 | p02273 | u264972437 | 1501304795 | Python | Python3 | py | Runtime Error | 0 | 0 | 557 | import math
def koch(p2, n, points):
p1 = points[-1]
x, y = p2[0]-p1[0], p2[1]-p1[1]
s = [p1[0]+x/3, p1[1]+y/3]
t = [p1[0]+x*2/3, p1[1]+y*2/3]
r = (x**2 + y**2) ** 0.5 / 3
theta = math.atan(y/x) + math.pi/3
u = [s[0]+r*math.cos(theta), s[1]+r*math.sin(theta)]
if n == 1:
points.extend([s,u,t,p2])
else:
koch(s, n-1, points)
koch(u, n-1, points)
koch(t, n-1, points)
koch(p2, n-1, points)
if __name__ == '__main__':
n = int(input())
p1 = [0.0, 0.0]
p2 = [100.0, 0.0]
points = [p1]
koch(p2, n, points)
[print(*p) for p in points] |
s752173868 | p02273 | u260980560 | 1501667410 | Python | Python3 | py | Runtime Error | 0 | 0 | 582 | from math import sqrt
q3 = sqrt(3)
fmt = "%.8f %.8f"
def koch(x0, y0, x1, y1, c):
xp = (x0*2 + x1) / 3
yp = (y0*2 + y1) / 3
xq = (x0 + x1*2) / 3
yq = (y0 + y1*2) / 3
dx = (x1 - x0) / 6
dy = (y1 - y0) / 6
xr = xp + (dx - dy * q3)
yr = yp + (dx * q3 + dy)
if c == n-1:
return (fmt % (x0, y0), fmt % (xp, yp), fmt % (xr, yr), fmt % (xq, yq))
return koch(x0, y0, xp, yp, c+1) + koch(xp, yp, xr, yr, c+1) + koch(xr, yr, xq, yq, c+1) + koch(xq, yq, x1, y1, c+1)
n = int(input())
print(*koch(0, 0, 100, 0, 0)+(fmt % (100, 0),), sep='\n') |
s625479358 | p02273 | u846136461 | 1510475051 | Python | Python | py | Runtime Error | 0 | 0 | 1168 | import math
n = int(raw_input())
def vector_rot(vector, radian):
new_x = vector[0] * math.cos(radian) - vector[1] * math.sin(radian)
new_y = vector[0] * math.sin(radian) + vector[1] * math.cos(radian)
return [new_x, new_y]
def vector_add(v1, v2):
new_v = []
for i in range(2):
add = v1[i] + v2[i]
new_v.append(add)
return new_v
def makepoint(p_A1, p_A2):
x_p_C1 = (p_A2[0] - p_A1[0]) / 3 + p_A1[0]
y_p_C1 = (p_A2[1] - p_A1[1]) / 3 + p_A1[1]
x_p_C3 = (p_A2[0] - p_A1[0]) * 2 / 3 + p_A1[0]
y_p_C3 = (p_A2[1] - p_A1[1]) * 2 / 3 + p_A1[1]
p_C1 = [x_p_C1, y_p_C1]
p_C3 = [x_p_C3, y_p_C3]
v01 = [x_p_C1 - p_A1[0], y_p_C1 - p_A1[1]]
rot_v01 = vector_rot(v01, 60 * math.pi / 180)
v02 = vector_add(v01, rot_v01)
p_C2 = vector_add(p_A1, v02)
C = [p_C1, p_C2, p_C3]
return C
A = [[0., 0.],[100., 0.]]
for i in range(n):
B = []
for j in range(len(A)-1): #A[j]??¨A[j+1]
C = makepoint(A[j], A[j+1]) #C = [p_C1, p_C2, p_C3]
B.append(A[j])
for p in C:
B.append(p)
#A[j+1]????¬????makepoint?????????append??????
B.append(A[-1]) #??????????????\?????\??????
A = B
for x in A:
print("{:.8f}".format(x[0])),
print("{:.8f}".format(x[1])) |
s807626700 | p02273 | u846136461 | 1510475153 | Python | Python | py | Runtime Error | 0 | 0 | 1168 | import math
n = int(raw_input())
def vector_rot(vector, radian):
new_x = vector[0] * math.cos(radian) - vector[1] * math.sin(radian)
new_y = vector[0] * math.sin(radian) + vector[1] * math.cos(radian)
return [new_x, new_y]
def vector_add(v1, v2):
new_v = []
for i in range(2):
add = v1[i] + v2[i]
new_v.append(add)
return new_v
def makepoint(p_A1, p_A2):
x_p_C1 = (p_A2[0] - p_A1[0]) / 3 + p_A1[0]
y_p_C1 = (p_A2[1] - p_A1[1]) / 3 + p_A1[1]
x_p_C3 = (p_A2[0] - p_A1[0]) * 2 / 3 + p_A1[0]
y_p_C3 = (p_A2[1] - p_A1[1]) * 2 / 3 + p_A1[1]
p_C1 = [x_p_C1, y_p_C1]
p_C3 = [x_p_C3, y_p_C3]
v01 = [x_p_C1 - p_A1[0], y_p_C1 - p_A1[1]]
rot_v01 = vector_rot(v01, 60 * math.pi / 180)
v02 = vector_add(v01, rot_v01)
p_C2 = vector_add(p_A1, v02)
C = [p_C1, p_C2, p_C3]
return C
A = [[0., 0.],[100., 0.]]
for i in range(n):
B = []
for j in range(len(A)-1): #A[j]??¨A[j+1]
C = makepoint(A[j], A[j+1]) #C = [p_C1, p_C2, p_C3]
B.append(A[j])
for p in C:
B.append(p)
#A[j+1]????¬????makepoint?????????append??????
B.append(A[-1]) #??????????????\?????\??????
A = B
for x in A:
print("{:.8f}".format(x[0])),
print("{:.8f}".format(x[1])) |
s553030428 | p02273 | u152639966 | 1521823472 | Python | Python3 | py | Runtime Error | 0 | 0 | 491 | import numpy as np
n=int(input())
p1=[0,0]
p2=[100,0]
def Koch(d,p1,p2):
if d==0:
return
sx=(2*p1[0]+p2[0])/3
sy=(2*p1[1]+p2[1])/3
tx=(p1[0]+2*p2[0])/3
ty=(p1[1]+2*p2[1])/3
ux=(tx-sx)*np.cos(np.pi/3)-(ty-sy)*np.sin(np.pi/3)+sx
uy=(tx-sx)*np.cos(np.pi/3)+(ty-sy)*np.sin(np.pi/3)+sy
Koch(d-1,p1,[sx,sy])
print(sx,sy)
Koch(d-1,[sx,sy],[ux,uy])
print(ux,uy)
Koch(d-1,[ux,uy],[tx,ty])
print(tx,ty)
Koch(d-1,[tx,ty],p2)
print(p1[0],p1[1])
Koch(n,p1,p2)
print(p2[0],p2[1])
|
s141330935 | p02273 | u152639966 | 1521823617 | Python | Python3 | py | Runtime Error | 0 | 0 | 519 | import numpy as np
n=int(input())
p1=[float(0),float(0)]
p2=[float(100),float(0)]
def Koch(d,p1,p2):
if d==0:
return
sx=(2*p1[0]+p2[0])/3
sy=(2*p1[1]+p2[1])/3
tx=(p1[0]+2*p2[0])/3
ty=(p1[1]+2*p2[1])/3
ux=(tx-sx)*np.cos(np.pi/3)-(ty-sy)*np.sin(np.pi/3)+sx
uy=(tx-sx)*np.cos(np.pi/3)+(ty-sy)*np.sin(np.pi/3)+sy
Koch(d-1,p1,[sx,sy])
print(sx,sy)
Koch(d-1,[sx,sy],[ux,uy])
print(ux,uy)
Koch(d-1,[ux,uy],[tx,ty])
print(tx,ty)
Koch(d-1,[tx,ty],p2)
print(p1[0],p1[1])
Koch(n,p1,p2)
print(p2[0],p2[1])
|
s390251817 | p02273 | u196653484 | 1527155625 | Python | Python3 | py | Runtime Error | 0 | 0 | 980 | import math
from matplotlib import pyplot
class Dot:
x=0.0
y=0.0
def __init__(self,x,y):
self.x=x
self.y=y
def __lt__(self,other):
return self.x < other.x
def print(self):
x=self.x
y=self.y
print("{:.8f} {:.8f}".format(x,y))
def kock(n,a,b,dots):
if n == 0:
return
s=Dot((2*a.x+b.x)/3,(2*a.y+b.y)/3)
t=Dot((a.x+2*b.x)/3,(a.y+2*b.y)/3)
rad=math.radians(60)
x=(t.x-s.x)*math.cos(rad)-(t.y-s.y)*math.sin(rad)+s.x
y=(t.x-s.x)*math.sin(rad)+(t.y-s.y)*math.cos(rad)+s.y
u=Dot(x,y)
kock(n-1,a,s,dots)
s.print()
dots.append(s)
kock(n-1,s,u,dots)
u.print()
dots.append(u)
kock(n-1,u,t,dots)
t.print()
dots.append(t)
kock(n-1,t,b,dots)
if __name__ == "__main__":
n=int(input())
dots=[]
dot1=Dot(0,0)
dot2=Dot(100,0)
dots.append(dot1)
dots.append(dot2)
dot1.print()
kock(n,dot1,dot2,dots)
dot2.print()
|
s476159247 | p02273 | u609614788 | 1527601666 | Python | Python3 | py | Runtime Error | 0 | 0 | 708 | #include<iostream>
#include<cstdio>
#include<cmath>
int n;
Struct Point{
double x;
double y;
}
void calc(int m,Point p1,Point p2){
if(m>=n){
return;
}
Point s,t,u;
s.x=(2*p1.x+1*p2.x)/3.0;
s.y=(2*p1.y+1*p2.y)/3.0;
t.x=(1*p1.x+2*p2.x)/3.0;
s.y=(1*p1.y+2*p2.y)/3.0;
u.x=(t.x-s.x)*(1/2.0)-(t.y-s.y)*(sqrt(3)/2.0)+s.x;
u.x=(t.x-s.x)*(sqrt(3)/2.0)+(t.y-s.y)*(1/2.0)+s.y;
calc(m+1,p1,s);
printf("%.8f %.8f\n,s.x,s.y);
calc(m+1,s,u);
printf("%.8f %.8f\n,u.x,u.y);
calc(m+1,u,t);
printf("%.8f %.8f\n,t.x,t.y);
calc(m+1,t,p2);
}
int main(){
std::cin>>n;
Point p1,p2;
p1.x=0; p1.y=0; p2.x=100; p2.y=0;
printf("%.8f %.8f\n,p1.x,p1.y);
calc(0,p1,p2);
printf("%.8f %.8f\n,p2.x,p2.y);
retu
|
s027944143 | p02273 | u609614788 | 1527601967 | Python | Python3 | py | Runtime Error | 0 | 0 | 721 | #include<iostream>
#include<cstdio>
#include<cmath>
int n;
struct Point{
double x;
double y;
};
void calc(int m,Point p1,Point p2){
if(m>=n){
return;
}
Point s,t,u;
s.x=(2*p1.x+1*p2.x)/3.0;
s.y=(2*p1.y+1*p2.y)/3.0;
t.x=(1*p1.x+2*p2.x)/3.0;
s.y=(1*p1.y+2*p2.y)/3.0;
u.x=(t.x-s.x)*(1/2.0)-(t.y-s.y)*(sqrt(3)/2.0)+s.x;
u.x=(t.x-s.x)*(sqrt(3)/2.0)+(t.y-s.y)*(1/2.0)+s.y;
calc(m+1,p1,s);
printf("%.8f %.8f\n",s.x,s.y);
calc(m+1,s,u);
printf("%.8f %.8f\n",u.x,u.y);
calc(m+1,u,t);
printf("%.8f %.8f\n",t.x,t.y);
calc(m+1,t,p2);
}
int main(){
std::cin>>n;
Point p1,p2;
p1.x=0; p1.y=0; p2.x=100; p2.y=0;
printf("%.8f %.8f\n",p1.x,p1.y);
calc(0,p1,p2);
printf("%.8f %.8f\n",p2.x,p2.y);
return 0;
}
|
s653003410 | p02273 | u609614788 | 1527602386 | Python | Python3 | py | Runtime Error | 0 | 0 | 732 | #include<iostream>
#include<cstdio>
#include<cmath>
int n;
struct Point{
double x;
double y;
};
void calc(int m,Point p1,Point p2){
if(m>=n){
return;
}
Point s,t,u;
s.x=(2.0*p1.x+p2.x)/3.0;
s.y=(2.0*p1.y+p2.y)/3.0;
t.x=(p1.x+2.0*p2.x)/3.0;
t.y=(p1.y+2.0*p2.y)/3.0;
u.x=(t.x-s.x)*(1.0/2.0)-(t.y-s.y)*(sqrt(3.0)/2.0)+s.x;
u.x=(t.x-s.x)*(sqrt(3.0)/2.0)+(t.y-s.y)*(1.0/2.0)+s.y;
calc(m+1,p1,s);
printf("%.8f %.8f\n",s.x,s.y);
calc(m+1,s,u);
printf("%.8f %.8f\n",u.x,u.y);
calc(m+1,u,t);
printf("%.8f %.8f\n",t.x,t.y);
calc(m+1,t,p2);
}
int main(){
std::cin>>n;
Point p1,p2;
p1.x=0; p1.y=0; p2.x=100; p2.y=0;
printf("%.8f %.8f\n",p1.x,p1.y);
calc(0,p1,p2);
printf("%.8f %.8f\n",p2.x,p2.y);
return 0;
}
|
s736131296 | p02273 | u481571686 | 1527661280 | Python | Python3 | py | Runtime Error | 0 | 0 | 699 | import math
n = int(input())
def koch(n,x_0,y_0,x_1,y_1):
if n == 0:
return
x_s = x_0 + (x_1- x_0)/3
y_s = y_0 + (y_1 -y_0)/3
x_t = x_0 + (x_1- x_0)* 2/3
y_t = y_0 + (y_1 -y_0) *2/3
x_u = (x_t - x_s) * math.cos(math.pi/3) - (y_t - y_s) * math.sin(math.pi/3) + x_s
y_u = (x_t - x_s) * math.sin(math.pi/3) + (y_t - y_s) * math.cos(math.pi/3) + y_s
koch(n-1,x_0,y_0,x_s,y_s)
print(x_s,y_s)
koch(n-1,x_s,y_s,x_u,y_u)
print(x_u,y_u)
koch(n-1,x_u,y_u,x_t,y_t)
print(x_t,y_t)
koch(n-1,x_t,y_t,x_1,y_1)
print(0,0)
koch(n,0,0,100,0)
print(100,0)
|
s522971942 | p02273 | u404682284 | 1527925867 | Python | Python3 | py | Runtime Error | 0 | 0 | 621 | from math import sqrt
from numpy import array
def koch(n, start, end):
if n != 0:
vec = end - start
normal_vec = array([-vec[1], vec[0]])
a = start + vec/3
b = start + vec/2 + sqrt(3)*normal_vec/6
c = end - vec/3
koch(n-1, start, a)
print('{0:.5f} {1:.5f}'.format(a[0], a[1]))
koch(n-1, a, b)
print('{0:.5f} {1:.5f}'.format(b[0], b[1]))
koch(n-1, b, c)
print('{0:.5f} {1:.5f}'.format(c[0], c[1]))
koch(n-1, c, end)
n = int(input())
print('0.0 100.0')
koch(n, array([0.0,0.0]), array([100.0,0.0]))
print('100.0 0.0')
|
s097582082 | p02273 | u404682284 | 1527925920 | Python | Python3 | py | Runtime Error | 0 | 0 | 637 | from math import sqrt
from numpy import array
def koch(n, start, end):
if n != 0:
vec = end - start
normal_vec = array([-vec[1], vec[0]])
a = start + vec/3
b = start + vec/2 + sqrt(3)*normal_vec/6
c = end - vec/3
koch(n-1, start, a)
print('{0:.5f} {1:.5f}'.format(a[0], a[1]))
koch(n-1, a, b)
print('{0:.5f} {1:.5f}'.format(b[0], b[1]))
koch(n-1, b, c)
print('{0:.5f} {1:.5f}'.format(c[0], c[1]))
koch(n-1, c, end)
n = int(input())
print('0.00000 100.00000')
koch(n, array([0.0,0.0]), array([100.0,0.0]))
print('100.00000 0.00000')
|
s659698382 | p02273 | u404682284 | 1527925948 | Python | Python3 | py | Runtime Error | 0 | 0 | 635 | from math import sqrt
from numpy import array
def koch(n, start, end):
if n != 0:
vec = end - start
normal_vec = array([-vec[1], vec[0]])
a = start + vec/3
b = start + vec/2 + sqrt(3)*normal_vec/6
c = end - vec/3
koch(n-1, start, a)
print('{0:.5f} {1:.5f}'.format(a[0], a[1]))
koch(n-1, a, b)
print('{0:.5f} {1:.5f}'.format(b[0], b[1]))
koch(n-1, b, c)
print('{0:.5f} {1:.5f}'.format(c[0], c[1]))
koch(n-1, c, end)
n = int(input())
print('0.00000 0.00000')
koch(n, array([0.0,0.0]), array([100.0,0.0]))
print('100.00000 0.00000')
|
s647960569 | p02273 | u404682284 | 1527926222 | Python | Python3 | py | Runtime Error | 0 | 0 | 578 | from math import sqrt
from numpy import array
def koch(n, start, end):
if n != 0:
vec = end - start
normal_vec = array([-vec[1], vec[0]])
a = start + vec/3
b = start + vec/2 + sqrt(3)*normal_vec/6
c = end - vec/3
koch(n-1, start, a)
print(a[0], a[1])
koch(n-1, a, b)
print(b[0], b[1])
koch(n-1, b, c)
print(c[0], c[1])
koch(n-1, c, end)
n = int(input())
start = array([0.0, 0.0])
end = array([100.0,0.0])
print(start[0], end[1])
koch(n, start, end)
print(start[0], end[1])
|
s429255703 | p02273 | u007270338 | 1528023656 | Python | Python3 | py | Runtime Error | 0 | 0 | 712 | #coding:utf-8
import numpy as np
import math
pi = math.pi
cos = math.cos
sin = math.sin
n = int(input())
A, B = np.array([0,0]), np.array([100,0])
def inc(A, B):
AB = B - A
rot = np.array([[cos(pi/2), -sin(pi/2)],[sin(pi/2), cos(pi/2)]])
convertedAB = np.dot(rot, AB)
normAB = np.linalg.norm(AB)
D = AB / 2 + (3**(1/2)/6) * convertedAB
return D
def koch(A, B, i):
AB = B - A
if i >= n:
return 1
C = A + AB/3
koch(A,C,i+1)
print(C)
D = inc(A, B)
koch(C,D,i+1)
print(D)
E = A + 2*AB/3
koch(D,E,i+1)
print(E)
koch(E,B,i+1)
koch(A, C, i+1),koch(C, D, i+1), koch(D, E, i+1), koch(E,B,i+1)
print(A)
i = 0
koch(A,B,i)
print(B)
|
s912675409 | p02273 | u007270338 | 1528023872 | Python | Python3 | py | Runtime Error | 0 | 0 | 872 | #coding:utf-8
import numpy as np
import math
pi = math.pi
cos = math.cos
sin = math.sin
n = int(input())
A, B = np.array([0,0]), np.array([100,0])
def inc(A, B):
AB = B - A
rot = np.array([[cos(pi/2), -sin(pi/2)],[sin(pi/2), cos(pi/2)]])
convertedAB = np.dot(rot, AB)
normAB = np.linalg.norm(AB)
D = AB / 2 + (3**(1/2)/6) * convertedAB
return D
def koch(A, B, i):
AB = B - A
if i >= n:
return 1
C = A + AB/3
koch(A,C,i+1)
print(" ".join([str(num) for num in C]))
D = inc(A, B)
koch(C,D,i+1)
print(" ".join([str(num) for num in D]))
E = A + 2*AB/3
koch(D,E,i+1)
print(" ".join([str(num) for num in E]))
koch(E,B,i+1)
koch(A, C, i+1),koch(C, D, i+1), koch(D, E, i+1), koch(E,B,i+1)
print(" ".join([str(num) for num in A]))
i = 0
koch(A,B,i)
print(" ".join([str(num) for num in B]))
|
s742600329 | p02273 | u007270338 | 1528024104 | Python | Python3 | py | Runtime Error | 0 | 0 | 914 | #coding:utf-8
import numpy as np
import math
pi = math.pi
cos = math.cos
sin = math.sin
n = int(input())
A, B = np.array([0,0]), np.array([100,0])
try:
n2 = input()
except:
pass
def inc(A, B):
AB = B - A
rot = np.array([[cos(pi/2), -sin(pi/2)],[sin(pi/2), cos(pi/2)]])
convertedAB = np.dot(rot, AB)
normAB = np.linalg.norm(AB)
D = AB / 2 + (3**(1/2)/6) * convertedAB
return D
def koch(A, B, i):
AB = B - A
if i >= n:
return 1
C = A + AB/3
koch(A,C,i+1)
print(" ".join([str(num) for num in C]))
D = inc(A, B)
koch(C,D,i+1)
print(" ".join([str(num) for num in D]))
E = A + 2*AB/3
koch(D,E,i+1)
print(" ".join([str(num) for num in E]))
koch(E,B,i+1)
koch(A, C, i+1),koch(C, D, i+1), koch(D, E, i+1), koch(E,B,i+1)
print(" ".join([str(num) for num in A]))
i = 0
koch(A,B,i)
print(" ".join([str(num) for num in B]))
|
s570757480 | p02273 | u007270338 | 1528024171 | Python | Python3 | py | Runtime Error | 0 | 0 | 871 | #coding:utf-8
import numpy as np
import math
pi = math.pi
cos = math.cos
sin = math.sin
n = int(input())
A, B = np.array([0,0]), np.array([100,0])
def inc(A, B):
AB = B - A
rot = np.array([[cos(pi/2), -sin(pi/2)],[sin(pi/2), cos(pi/2)]])
convertedAB = np.dot(rot, AB)
normAB = np.linalg.norm(AB)
D = AB / 2 + (3**(1/2)/6) * convertedAB
return D
def koch(A, B, i):
AB = B - A
if i >= n:
return 1
C = A + AB/3
koch(A,C,i+1)
print(" ".join([str(num) for num in C]))
D = inc(A, B)
koch(C,D,i+1)
print(" ".join([str(num) for num in D]))
E = A + 2*AB/3
koch(D,E,i+1)
print(" ".join([str(num) for num in E]))
koch(E,B,i+1)
koch(A, C, i+1),koch(C, D, i+1), koch(D, E, i+1), koch(E,B,i+1)
print(" ".join([str(num) for num in A]))
i = 0
koch(A,B,i)
print(" ".join([str(num) for num in B]))
|
s933020325 | p02273 | u007270338 | 1528024750 | Python | Python3 | py | Runtime Error | 0 | 0 | 871 | #coding:utf-8
import numpy as np
import math
pi = math.pi
cos = math.cos
sin = math.sin
n = int(input())
A, B = np.array([0,0]), np.array([100,0])
def inc(A, B):
AB = B - A
rot = np.array([[cos(pi/2), -sin(pi/2)],[sin(pi/2), cos(pi/2)]])
convertedAB = np.dot(rot, AB)
normAB = np.linalg.norm(AB)
D = AB / 2 + (3**(1/2)/6) * convertedAB
return D
def koch(A, B, i):
AB = B - A
if i >= n:
return 1
C = A + AB/3
koch(A,C,i+1)
print(" ".join([str(num) for num in C]))
D = inc(A, B)
koch(C,D,i+1)
print(" ".join([str(num) for num in D]))
E = A + 2*AB/3
koch(D,E,i+1)
print(" ".join([str(num) for num in E]))
koch(E,B,i+1)
koch(A, C, i+1),koch(C, D, i+1), koch(D, E, i+1), koch(E,B,i+1)
print(" ".join([str(num) for num in A]))
i = 0
koch(A,B,i)
print(" ".join([str(num) for num in B]))
|
s927461778 | p02273 | u007270338 | 1528024796 | Python | Python3 | py | Runtime Error | 0 | 0 | 904 | #coding:utf-8
import numpy as np
import math
pi = math.pi
cos = math.cos
sin = math.sin
n = int(input())
if n == 0:
n = int(input())
A, B = np.array([0,0]), np.array([100,0])
def inc(A, B):
AB = B - A
rot = np.array([[cos(pi/2), -sin(pi/2)],[sin(pi/2), cos(pi/2)]])
convertedAB = np.dot(rot, AB)
normAB = np.linalg.norm(AB)
D = AB / 2 + (3**(1/2)/6) * convertedAB
return D
def koch(A, B, i):
AB = B - A
if i >= n:
return 1
C = A + AB/3
koch(A,C,i+1)
print(" ".join([str(num) for num in C]))
D = inc(A, B)
koch(C,D,i+1)
print(" ".join([str(num) for num in D]))
E = A + 2*AB/3
koch(D,E,i+1)
print(" ".join([str(num) for num in E]))
koch(E,B,i+1)
koch(A, C, i+1),koch(C, D, i+1), koch(D, E, i+1), koch(E,B,i+1)
print(" ".join([str(num) for num in A]))
i = 0
koch(A,B,i)
print(" ".join([str(num) for num in B]))
|
s150258212 | p02273 | u007270338 | 1528024881 | Python | Python3 | py | Runtime Error | 0 | 0 | 916 | #coding:utf-8
import numpy as np
import math
pi = math.pi
cos = math.cos
sin = math.sin
n = int(input())
if n == 0:
n = int(input())
A, B = np.array([0,0]), np.array([100,0])
def inc(A, B):
AB = B - A
rot = np.array([[cos(pi/2), -sin(pi/2)],[sin(pi/2), cos(pi/2)]])
convertedAB = np.dot(rot, AB)
normAB = np.linalg.norm(AB)
D = AB / 2 + (3**(1/2)/6) * convertedAB
return D
def koch(A, B, i):
AB = B - A
if i >= n:
return 1
C = A + AB/3
koch(A,C,i+1)
print(" ".join([str(num) for num in C]))
D = inc(A, B)
koch(C,D,i+1)
print(" ".join([str(num) for num in D]))
E = A + 2*AB/3
koch(D,E,i+1)
print(" ".join([str(num) for num in E]))
koch(E,B,i+1)
koch(A, C, i+1),koch(C, D, i+1), koch(D, E, i+1), koch(E,B,i+1)
print(" ".join([str(flaot(num)) for num in A]))
i = 0
koch(A,B,i)
print(" ".join([str(float(num)) for num in B]))
|
s849656790 | p02273 | u007270338 | 1528024967 | Python | Python3 | py | Runtime Error | 0 | 0 | 916 | #coding:utf-8
import numpy as np
import math
pi = math.pi
cos = math.cos
sin = math.sin
n = int(input())
if n == 0:
n = int(input())
A, B = np.array([0,0]), np.array([100,0])
def inc(A, B):
AB = B - A
rot = np.array([[cos(pi/2), -sin(pi/2)],[sin(pi/2), cos(pi/2)]])
convertedAB = np.dot(rot, AB)
normAB = np.linalg.norm(AB)
D = AB / 2 + (3**(1/2)/6) * convertedAB
return D
def koch(A, B, i):
AB = B - A
if i >= n:
return 1
C = A + AB/3
koch(A,C,i+1)
print(" ".join([str(num) for num in C]))
D = inc(A, B)
koch(C,D,i+1)
print(" ".join([str(num) for num in D]))
E = A + 2*AB/3
koch(D,E,i+1)
print(" ".join([str(num) for num in E]))
koch(E,B,i+1)
koch(A, C, i+1),koch(C, D, i+1), koch(D, E, i+1), koch(E,B,i+1)
print(" ".join([str(float(num)) for num in A]))
i = 0
koch(A,B,i)
print(" ".join([str(float(num)) for num in B]))
|
s625306241 | p02273 | u007270338 | 1528024999 | Python | Python3 | py | Runtime Error | 0 | 0 | 884 | #coding:utf-8
import numpy as np
import math
pi = math.pi
cos = math.cos
sin = math.sin
n = int(input())
A, B = np.array([0,0]), np.array([100,0])
def inc(A, B):
AB = B - A
rot = np.array([[cos(pi/2), -sin(pi/2)],[sin(pi/2), cos(pi/2)]])
convertedAB = np.dot(rot, AB)
normAB = np.linalg.norm(AB)
D = AB / 2 + (3**(1/2)/6) * convertedAB
return D
def koch(A, B, i):
AB = B - A
if i >= n:
return 1
C = A + AB/3
koch(A,C,i+1)
print(" ".join([str(num) for num in C]))
D = inc(A, B)
koch(C,D,i+1)
print(" ".join([str(num) for num in D]))
E = A + 2*AB/3
koch(D,E,i+1)
print(" ".join([str(num) for num in E]))
koch(E,B,i+1)
koch(A, C, i+1),koch(C, D, i+1), koch(D, E, i+1), koch(E,B,i+1)
print(" ".join([str(float(num)) for num in A]))
i = 0
koch(A,B,i)
print(" ".join([str(float(num)) for num in B]))
|
s861932741 | p02273 | u912237403 | 1371341699 | Python | Python | py | Runtime Error | 0 | 0 | 555 | import math, cmath
def koch(p1, p2, n):
rad60 = math.pi/3
v1 = (p2 - p1)/3
v2 = cmath.rect(abs(v1), cmath.phase(v1)+rad60)
q1 = p1 + v1
q2 = q1 + v2
q3 = q1 + v1
if n == 1:
return [p1,q1,q2,q3,p2]
else:
x1 = koch(p1,q1,n-1)[1:-1]
x2 = koch(q1,q2,n-1)[1:-1]
x3 = koch(q2,q3,n-1)[1:-1]
x4 = koch(q3,p2,n-1)[1:-1]
x = [p1]+x1+[q1]+x2+[q2]+x3+[q3]+x4+[p2]
return x
n = int(raw_input())
p1 = complex(0,0)
p2 = complex(100,0)
for e in koch(p1,p2,n):
print e.real,e.imag |
s080332170 | p02273 | u912237403 | 1371341932 | Python | Python | py | Runtime Error | 10 | 4444 | 567 | import math, cmath
def koch(p1, p2, n):
if n == 0:
return [p1, p2]
rad60 = math.pi/3
v1 = (p2 - p1)/3
v2 = cmath.rect(abs(v1), cmath.phase(v1)+rad60)
q1 = p1 + v1
q2 = q1 + v2
q3 = q1 + v1
if n == 1:
return [p1,q1,q2,q3,p2]
else:
x1 = koch(p1,q1,n-1)[-1]
x2 = koch(q1,q2,n-1)[-1]
x3 = koch(q2,q3,n-1)[-1]
x4 = koch(q3,p2,n-1)
x = x1 + x2 + x3 + x4
return x
n = int(raw_input())
p1 = complex(0,0)
p2 = complex(100,0)
for e in koch(p1,p2,n):
print e.real,e.imag |
s531408782 | p02274 | u792145349 | 1535245835 | Python | Python3 | py | Runtime Error | 20 | 5596 | 520 | N = int(input())
A = list(map(int, input().split()))
class BinaryIndexedTree:
def __init__(self, n):
self.size = n
self.bit = [0] * (n + 1)
def sum(self, i):
s = 0
while i > 0:
s += self.bit[i]
i -= (i & -i)
return s
def add(self, i, x):
while i <= self.size:
self.bit[i] += x
i += (i & -i)
BIT = BinaryIndexedTree(N)
ans = 0
for j in range(N):
ans += j - BIT.sum(A[j])
BIT.add(A[j], 1)
print(ans)
|
s719252766 | p02274 | u316584871 | 1535618402 | Python | Python3 | py | Runtime Error | 0 | 0 | 245 | rom collections import deque
n = int(input())
nd = deque(map(int, input().split()))
c = 0
for i in range(n):
m = min(nd)
s = nd.popleft()
if (s != m):
for k in nd:
if (k < s):
c += 1
print(c)
|
s516937431 | p02274 | u464296040 | 1535672817 | Python | Python3 | py | Runtime Error | 0 | 0 | 2617 | #include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <cstring>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define Cout(obj) cout << obj << endl
#define Size(obj) (int)(obj).size()
#define fcout cout << fixed << setprecision(10)
#define fi first
#define se second
using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
int to, cost;
};
const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template <typename T>
class BIT
{
private:
vector<T> array;
int N;
public:
BIT(int size) : array(size + 1, 0), N(size) {}
T sum(int i)
{
T sum = 0;
while (i > 0)
{
sum += array[i];
i -= i & -i;
}
return sum;
}
T sum(int l, int r)
{
T res_l = sum(l - 1);
T res_r = sum(r);
return res_r - res_l;
}
void add(int i, T x)
{
while (i <= N)
{
array[i] += x;
i += i & -i;
}
}
int lower_bound(int w)
{
if (w <= 0)
{
return 0;
}
int init = 1;
while(init < N)
{
init *= 2;
}
int x = 0;
for(int k = init; k > 0; k /= 2)
{
if(x + k <= N && array[x + k] < w)
{
w -= array[x + k];
x += k;
}
}
return x + 1;
}
};
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
vector<int> a(N);
BIT<int> bit(N);
REP(i, N)
{
cin >> a[i];
}
ll ans = 0;
REP(i, N)
{
ans += bit.sum(a[i], N);
bit.add(a[i], 1);
}
Cout(ans);
return 0;
}
|
s039460182 | p02274 | u309159632 | 1540601968 | Python | Python3 | py | Runtime Error | 20 | 5596 | 552 | # 5
# 3 5 2 1 4
def cum(i):
res = 0
while i>0:
res += bit[i]
i -= i&-i
return res
def add(i, x):
while i<=N:
bit[i] += x
i += i&-i
def solve():
global N,A,bit
N = int(input())
A = list(map(int, input().split()))
bit = [0]*(N+1)
res = 0
for i in range(N):
res += cum(A[i])
add(A[i], 1)
print(N*(N-1)//2-res)
return 0
if __name__ == "__main__":# {{{
try:
local_input()
except:
pass
solve()
# vim: set foldmethod=marker:}}}
|
s674371504 | p02274 | u309159632 | 1540602094 | Python | Python3 | py | Runtime Error | 20 | 5600 | 459 | # 5
# 3 5 2 1 4
def cum(i):
res = 0
while i>0:
res += bit[i]
i -= i&-i
return res
def add(i, x):
while i<=N:
bit[i] += x
i += i&-i
def solve():
global N,A,bit
N = int(input())
A = list(map(int, input().split()))
bit = [0]*(N+1)
res = 0
for i in range(N):
res += cum(A[i])
add(A[i], 1)
print(N*(N-1)//2-res)
return 0
if __name__ == "__main__":
solve()
|
s391162721 | p02274 | u981699375 | 1546133354 | Python | Python3 | py | Runtime Error | 0 | 0 | 1442 | import std.array, std.stdio, std.conv, std.string, std.math, std.random, std.range,std.functional;
import std.algorithm.searching, std.algorithm.sorting, std.algorithm.iteration, std.algorithm.comparison;
int count;
void main()
{
readln();
int[] list = readln().split.to!(int[]);
writeln(count);
}
int[] merge(int[] a, int[] b)
{
int[] res;
res.reserve(a.length+b.length);
while(a.length != 0 && b.length != 0)
{
if(a.front < b.front)
{
res ~= a.front;
a.popFront();
}else{
count+=a.length;
res ~= b.front;
b.popFront();
}
}
res ~= a ~ b;
return res;
}
int[] mergeSort(int[] list)
{
if(list.length == 0)
return list;
if(list.length == 1)
return list;
auto mid = list.length / 2;
auto a = mergeSort(list[0..mid]);
auto b = mergeSort(list[mid..$]);
return merge(a, b);
}
sizediff_t minIndex(alias pred="a<b", R) (R list)
if(isForwardRange!R && !isInfinite!R && is(typeof(binaryFun!pred(list.front, list.front))))
{
assert(!list.empty);
typeof(list.front) min = list.front;
sizediff_t minPos;
sizediff_t curPos;
for(list.popFront(); !list.empty; list.popFront())
{
curPos++;
if(binaryFun!pred(list.front, min))
{
min = list.front;
minPos = curPos;
}
}
return minPos;
}
|
s248915853 | p02274 | u981699375 | 1546133617 | Python | Python3 | py | Runtime Error | 0 | 0 | 1464 | import std.array, std.stdio, std.conv, std.string, std.math, std.random, std.range,std.functional;
import std.algorithm.searching, std.algorithm.sorting, std.algorithm.iteration, std.algorithm.comparison;
long count;
void main()
{
readln();
int[] list = readln().split.to!(int[]);
mergeSort(list);
writeln(count);
}
int[] merge(int[] a, int[] b)
{
int[] res;
res.reserve(a.length+b.length);
while(a.length != 0 && b.length != 0)
{
if(a.front < b.front)
{
res ~= a.front;
a.popFront();
}else{
count+=a.length;
res ~= b.front;
b.popFront();
}
}
res ~= a ~ b;
return res;
}
int[] mergeSort(int[] list)
{
if(list.length == 0)
return list;
if(list.length == 1)
return list;
auto mid = list.length / 2;
auto a = mergeSort(list[0..mid]);
auto b = mergeSort(list[mid..$]);
return merge(a, b);
}
sizediff_t minIndex(alias pred="a<b", R) (R list)
if(isForwardRange!R && !isInfinite!R && is(typeof(binaryFun!pred(list.front, list.front))))
{
assert(!list.empty);
typeof(list.front) min = list.front;
sizediff_t minPos;
sizediff_t curPos;
for(list.popFront(); !list.empty; list.popFront())
{
curPos++;
if(binaryFun!pred(list.front, min))
{
min = list.front;
minPos = curPos;
}
}
return minPos;
}
|
s413475351 | p02274 | u387603681 | 1556162142 | Python | Python3 | py | Runtime Error | 0 | 0 | 382 | global cnt = 0
def modify_order(A):
if len(A) < 2:
return
*B, hip, tail = A
if (hip > tail):
cnt += 1
return modify_order(B + [tail])+ [hip]
else:
return modify_order(B + [hip])+ [tail]
def sort(A):
if len(A) < 2:
return A
head, *B = modify_order(A)
return [head] + sort(B)
n = int(input())
*A, = map(int, input().split())
sort(A)
print(cnt)
|
s611186438 | p02274 | u797673668 | 1452485626 | Python | Python3 | py | Runtime Error | 30 | 7756 | 548 | class Bit:
def __init__(self, size):
self.arr = [0] * (size + 1)
self.size = size
def read(self, index):
sum_b = 0
while index:
sum_b += self.arr[index]
index &= index - 1
return sum_b
def update(self, index, value=1):
while index <= self.size:
self.arr[index] += value
index += index & -index
bit, a, inv = Bit(int(input())), list(map(int, input().split())), 0
for i in reversed(a):
inv += bit.read(i)
bit.update(i)
print(inv) |
s180731852 | p02274 | u072053884 | 1453479642 | Python | Python3 | py | Runtime Error | 20 | 7784 | 525 | def num_of_inversions(A, n, cnt = 0):
"""Return the number of inversions in the sequence A.
A is a list of numbers.
n is the length of A.
cnt is a accumulator.
"""
if n == 1:
return cnt
t_cnt = 0
t_lt = A[-1]
for i in reversed(A[:n - 1]):
if i > t_lt:
t_cnt += 1
return num_of_inversions(A[:n - 1], n - 1, cnt + t_cnt)
import sys
n = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))
ans = num_of_inversions(A, n)
print(ans) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.