ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1659. Regular Triangles

checker
Posted by ASK 17 Mar 2018 02:18
#!python3
s = """0 30
-25.9807621135 -15
25.9807621135 -15
3.711537444785714 10.714285714285715
-11.134612334357143 -2.142857142857144
7.423074889571431 -8.571428571428571
18.557687223928568 23.57142857142857
-29.69229955828571 4.285714285714285
11.134612334357145 -27.857142857142854"""

import matplotlib.pyplot as plt
from math import cos, sin, pi
fig = plt.figure()
ax = fig.add_subplot(111,aspect='equal')

r=[[float(a) for a in p.split()] for p in s.split("\n")]
def d(a,b): return (r[a][0]-r[b][0])**2 + (r[a][1]-r[b][1])**2
def z(a,b): return abs(a-b) < 1e-6

a = 0
for i in range(len(r)):
    for j in range(i+1,len(r)):
        for k in range(j+1,len(r)):
            if z(d(i,j),d(i,k)) and z(d(i,j),d(j,k)) and z(d(j,k),d(i,k)):
                a += 1
                x = [r[t][0] + 0.5*cos(2*pi*a/9) for t in (i,j,k,i)]
                y = [r[t][1] + 0.5*sin(2*pi*a/9) for t in (i,j,k,i)]
                plt.plot(x, y, '-')
for p in r: plt.plot(p[0],p[1],'bo')
plt.grid()
plt.show()
print(a)
Re: checker
Posted by sergovoy 4 Aug 2018 14:51
Thanks!