Development Project

[ Baekjoon - 단계별로 풀어보기(06/09~06/10) ] - 13단계 : 기하1 본문

CodingTest/Baekjoon

[ Baekjoon - 단계별로 풀어보기(06/09~06/10) ] - 13단계 : 기하1

나를 위한 시간 2022. 6. 9. 23:22
  • 1085 : 직사각형에서 탈출
x,y,w,h=map(int,input().split())
print(min([abs(x-w),abs(y-h),abs(x),abs(y)]))

 

  • 3009 : 네 번째 점
l=[]
for _ in range(3):
    l.extend(map(int,input().split()))
odd=l[0::2]
even=l[1::2]
print(min(odd) if odd.count(min(odd))==1 else max(odd), min(even) if even.count(min(even))==1 else max(even))

 

  • 4153 : 직각삼각형
while True:
    l=list(map(int,input().split()))
    if l[0]==0 and l[1]==0 and l[2]==0:
        break
    m=max(l)
    l.remove(m)
    print("right" if m**2==l[0]**2+l[1]**2 else "wrong")

 

  • 2477 : 참외밭
n=int(input())
l=[list(map(int,input().split())) for _ in range(6)]
width=0;w=0
height=0;h=0
for i in range(len(l)):
    if l[i][0] == 1 or l[i][0] == 2:
        if width<l[i][1]:
            width=l[i][1]
            w=i
    elif l[i][0] == 3 or l[i][0] == 4:
        if height<l[i][1]:
            height=l[i][1]
            h=i
    W=abs(l[(w-1)%6][1] - l[(w+1)%6][1])
    H=abs(l[(h-1)%6][1] - l[(h+1)%6][1])
print(((width*height)-(W*H))*n)

 

  • 3053 : 택시 기하학
import math
r = int(input())
print(f'{r*r*math.pi:.6f}')
print(f'{2*r*r:.6f}')

 

  • 1002 : 터렛
import sys
input=sys.stdin.readline
for i in range(int(input())):
    x1,y1,r1,x2,y2,r2=map(int,input().split())
    dist=((x1-x2)**2+(y1-y2)**2)**(1/2)
    print(-1 if dist==0 and r1==r2 and r1!=0 else (1 if (abs(r1-r2)==dist) or (r1+r2==dist) else (2 if abs(r1-r2)<dist<(r1+r2) else 0)))

 

  • 1004 : 어린 왕자
T=int(input())
for i in range(T):
    x1, y1, x2, y2 = map(int, input().split())
    res=0
    n=int(input())
    l=[]
    [l.append(list(map(int,input().split()))) for _ in range(n)]
    for j in range(n):
        x=l[j][0];y=l[j][1];r=l[j][2]
        s_dist = ((x1-x)**2+(y1-y)**2)**(1/2)
        e_dist = ((x2-x)**2+(y2-y)**2)**(1/2)
        se_dist = ((x1-x2)**2+(y1-y2)**2)**(1/2)
        res+=0 if s_dist<r and e_dist<r and se_dist<2*r else (1 if s_dist<r or e_dist<r else 0)
    print(res)

 

  • 1358 : 하키
width,height,x,y,pNum=map(int,input().split())
l=[];cnt=0
[l.append(list(map(int,input().split()))) for _ in range(pNum)]
for i in range(len(l)):
    tx=l[i][0];ty=l[i][1]
    left_r = ((x-tx)**2+(y+height/2-ty)**2)**(1/2)
    right_r = ((x+width-tx)**2+(y+height/2-ty)**2)**(1/2)
    if (tx<=x and left_r<=height/2) or (tx>=x+width and right_r<=height/2) or (x<=tx<=x+width and y<=ty<=y+height):
        cnt+=1
print(cnt)
Comments