Skip to content

Commit dc82596

Browse files
committed
1 week
1 parent 2b5b20b commit dc82596

File tree

8 files changed

+169
-0
lines changed

8 files changed

+169
-0
lines changed

01-240319/yunjaeeun44/1002.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
T = int(input())
2+
for i in range(T):
3+
x1, y1, r1, x2, y2, r2 = map(int, input().split())
4+
distance = ((x1-x2)**2 + (y1-y2)**2)**(1/2)
5+
if distance==0 and r1==r2: #동일
6+
print(-1)
7+
elif abs(r1-r2)==distance or r1+r2==distance: #내접, 외접
8+
print(1)
9+
elif abs(r1-r2) < distance < (r1+r2) : #두 점에서 만날 때
10+
print(2)
11+
else:
12+
print(0)

01-240319/yunjaeeun44/1003.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
T = int(input())
2+
for _ in range(T):
3+
N = int(input())
4+
a, b = 1, 0
5+
for i in range(N):
6+
a, b = b, a+b #DP
7+
print(a, b)

01-240319/yunjaeeun44/1004.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
T = int(input())
2+
for _ in range(T):
3+
x1, y1, x2, y2 = map(int, input().split())
4+
answer = 0
5+
N = int(input())
6+
for i in range(N):
7+
cx, cy, r = map(int, input().split())
8+
distance1 = ((cx-x1)**2 + (cy-y1)**2)**(1/2) #출발점과 원 중심의 거리
9+
distance2 = ((cx-x2)**2 + (cy-y2)**2)**(1/2) #출발점과 원 중심의 거리
10+
if distance1 < r and distance2 < r: #출발점과 도착점이 모두 원 안에 존재
11+
continue
12+
elif distance1 > r and distance2 > r: #출발점과 도착점이 모두 원 밖에 존재
13+
continue
14+
else: #출발점과 도착점 중 하나가 원 안에 존재
15+
answer += 1
16+
print(answer)

01-240319/yunjaeeun44/A.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
def solution(friends, gifts):
2+
givers = {}
3+
receivers = {}
4+
score = {}
5+
answer = {}
6+
#givers, receivers
7+
for friend in friends:
8+
givers[friend] = []
9+
receivers[friend] = []
10+
answer[friend] = 0
11+
for gift in gifts:
12+
giver, receiver = gift.split()
13+
givers[giver].append(receiver)
14+
receivers[receiver].append(giver)
15+
#score
16+
for friend in friends:
17+
score[friend] = len(givers.get(friend))-len(receivers.get(friend))
18+
#answer
19+
for friend in friends:
20+
#두 사람이 선물을 주고받은 기록 체크
21+
for other in friends:
22+
if other == friend:
23+
continue
24+
#선물을 주고받은 기록이 서로 같아서 선물 지수 체크
25+
if givers[friend].count(other) == givers[other].count(friend):
26+
if score[friend] > score[other]:
27+
answer[friend] += 1
28+
#선물을 주고받은 기록이 서로 다름
29+
elif givers[friend].count(other) > givers[other].count(friend):
30+
answer[friend] += 1
31+
return max(answer.values())

01-240319/yunjaeeun44/B.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from collections import Counter
2+
3+
def solution(edges):
4+
answer = [0, 0, 0, 0]
5+
dotChecks = {}
6+
for start, end in edges:
7+
if dotChecks.get(start) == None:
8+
dotChecks[start] = [0, 0]
9+
if dotChecks.get(end) == None:
10+
dotChecks[end] = [0, 0]
11+
dotChecks[start][0] += 1
12+
dotChecks[end][1] += 1
13+
for key, check in dotChecks.items():
14+
if check[0] >=2 and check[1] == 0: #생성한 정점
15+
answer[0] = key
16+
elif check[0]==2 and check[1]>=2: #8자 그래프(생성된 정점에서 나온 간선의 도착점일 경우 존재)
17+
answer[3] += 1
18+
elif check[0]==0:
19+
answer[2] += 1
20+
answer[1] = dotChecks[answer[0]][0] - answer[2] - answer[3]
21+
return answer

01-240319/yunjaeeun44/C.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from itertools import combinations, product
2+
from bisect import bisect_left
3+
4+
def solution(dice):
5+
wins_dict = {}
6+
#주사위 조합
7+
combsA = list(combinations(range(len(dice)), len(dice)//2))
8+
for combA in combsA:
9+
combB = []
10+
for i in range(len(dice)):
11+
if i not in combA:
12+
combB.append(i)
13+
14+
sumListA = [] #해당 주사위 조합에서 나올 수 있는 값
15+
sumListB = []
16+
for dice_product in product(range(6), repeat=len(dice)//2): #주사위면 중복 순열
17+
sumA = 0
18+
sumB = 0
19+
for i, j in zip(combA, dice_product):
20+
sumA += dice[i][j]
21+
for i, j in zip(combB, dice_product):
22+
sumB += dice[i][j]
23+
sumListA.append(sumA)
24+
sumListB.append(sumB)
25+
sumListB.sort()
26+
27+
wins = 0
28+
for sumA in sumListA:
29+
wins += bisect_left(sumListB, sumA)
30+
wins_dict[wins] = list(combA)
31+
32+
max_key = max(wins_dict.keys())
33+
answer = []
34+
for x in wins_dict[max_key]:
35+
answer.append(x+1)
36+
37+
return answer

01-240319/yunjaeeun44/D.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from collections import deque
2+
3+
def check(deck1, deck2, target):
4+
for card in deck1:
5+
if target - card in deck2:
6+
deck1.remove(card)
7+
deck2.remove(target-card)
8+
return True
9+
return False
10+
11+
12+
def solution(coin, cards):
13+
answer = 1
14+
hands = cards[:len(cards)//3]
15+
deck = deque(cards[len(cards) // 3:])
16+
draws = []
17+
18+
while coin >=0 and deck:
19+
draws.append(deck.popleft())
20+
draws.append(deck.popleft())
21+
22+
if check(hands, hands, len(cards) + 1):
23+
pass
24+
elif coin >= 1 and check(hands, draws, len(cards) + 1):
25+
coin -= 1
26+
elif coin >= 2 and check(draws, draws, len(cards) + 1):
27+
coin -= 2
28+
else:
29+
break
30+
answer += 1
31+
return answer

01-240319/yunjaeeun44/E.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
def solution(n, tops):
2+
MOD = 10007
3+
a = [0] * (n + 1) #오른쪽에 위치한 위 방향 삼각형 포함
4+
b = [0] * (n + 1) #오른쪽에 위치한 위 방향 삼각형 미포함
5+
a[0] = 0 #위 방향 삼각형 하나만 있을 때
6+
b[0] = 1
7+
for k in range(1, n + 1): #아래 방향 삼각형 하나씩 덮기
8+
if tops[k - 1]:
9+
a[k] = (a[k - 1] + b[k - 1]) % MOD
10+
b[k] = (2 * a[k - 1] + 3 * b[k - 1]) % MOD
11+
else:
12+
a[k] = (a[k - 1] + b[k - 1]) % MOD
13+
b[k] = (a[k - 1] + 2 * b[k - 1]) % MOD
14+
return (a[n] + b[n]) % MOD

0 commit comments

Comments
 (0)