아이공의 AI 공부 도전기

[Baekjoon] 1358번 : 하키 (Python, 수학)

 

     

 

 

https://www.acmicpc.net/problem/1358

 

1358번: 하키

첫째 줄에 수 W H X Y P가 주어진다. P는 선수의 수이다. W와 H는 100보다 작거나 같은 자연수이고, H는 짝수이다. X와 Y는 절댓값이 100보다 작거나 같은 정수이다. P는 최대 50인 자연수이다. 둘째 줄부

www.acmicpc.net

 

코드 링크

https://github.com/stellaluminary/Baekjoon

 

GitHub - stellaluminary/Baekjoon

Contribute to stellaluminary/Baekjoon development by creating an account on GitHub.

github.com

 

Python

 

방법 1 - 메모리 30840KB / 시간 72ms / 코드 길이 313B

 

w,h,x,y,p = map(int, input().split())
cnt = 0
r = h//2
for i in range(p):
    px, py = map(int, input().split())

    if (px-x)**2 + (py - (y+r))**2 <= r**2:
        cnt += 1
    elif x <= px <= x+w and y <= py <= y+h:
        cnt += 1
    elif (px-(x+w))**2 + (py - (y+r))**2 <= r**2:
        cnt += 1
print(cnt)

 

공유하기

facebook twitter kakaoTalk kakaostory naver band
loading