Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Thu Nov 19 20:58:30 2020
- @author: Sergey
- """
- import math
- def left_or_right(x,y,k):
- x1=0
- y1=0
- x2=1
- y2=k*x2
- D = (x - x1) * (y2 - y1) - (y - y1) * (x2 - x1)
- if D > 0:
- ans='right'
- elif D < 0:
- ans='left'
- elif D == 0:
- ans='on'
- return ans
- def len_h(x,y,k):
- if (left_or_right(x,y,k) == 'left') or(left_or_right(x,y,k) == 'right'):
- x1=y/k
- y1=k*x
- a=x1-x
- b=y1-y
- c=math.sqrt((a**2)+(b**2))
- ac=(a**2)/c
- bc=c-ac
- h=math.sqrt(ac*bc)
- else:
- h=-1
- return h
- x1,y1,x2,y2,x3,y3,k=float(input()),float(input()),float(input()),float(input()),float(input()),float(input()),float(input())
- a=[len_h(x1,y1,k),len_h(x2,y2,k),len_h(x3,y3,k)]
- print(a)
- ans=10**10
- if min(a)==-1:
- print(a.index(-1)+1)
- else:
- print(a.index(min(a))+1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement