Upload files to "백준"
This commit is contained in:
24
백준/0209_01.py
Normal file
24
백준/0209_01.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
from collections import deque
|
||||||
|
|
||||||
|
queue = deque
|
||||||
|
queue.popleft()
|
||||||
|
def solution(clothes):
|
||||||
|
arr=[]
|
||||||
|
temp=2
|
||||||
|
answer = 1
|
||||||
|
clothes.sort(key = lambda x:(x[1], x[0]))
|
||||||
|
maxvalue = len(clothes)
|
||||||
|
for i in range(0, maxvalue-1):
|
||||||
|
if (clothes[i][1] != clothes[i+1][1]):
|
||||||
|
arr.append(temp)
|
||||||
|
temp=2
|
||||||
|
else:
|
||||||
|
temp+=1
|
||||||
|
arr.append(temp)
|
||||||
|
for j in arr:
|
||||||
|
answer *= j
|
||||||
|
answer -= 1
|
||||||
|
queue
|
||||||
|
return answer
|
||||||
|
|
||||||
|
print(solution([["yellow_hat", "headgear"], ["blue_sunglasses", "eyewear"], ["green_turban", "headgear"]]))
|
||||||
28
백준/0209_01_01.py
Normal file
28
백준/0209_01_01.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
from collections import deque
|
||||||
|
|
||||||
|
def solution(bridge_length, weight, truck_weights):
|
||||||
|
queue = deque()
|
||||||
|
index = 0
|
||||||
|
seconds = 0
|
||||||
|
maxvalue=len(truck_weights)-1
|
||||||
|
now_weight=0
|
||||||
|
for _ in range(bridge_length):
|
||||||
|
queue.append(0)
|
||||||
|
while True:
|
||||||
|
seconds+=1
|
||||||
|
now_weight-=queue.popleft()
|
||||||
|
if(now_weight+truck_weights[index] <= weight):
|
||||||
|
queue.append(truck_weights[index])
|
||||||
|
now_weight+=truck_weights[index]
|
||||||
|
if(index==maxvalue):
|
||||||
|
seconds+=bridge_length
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
index+=1
|
||||||
|
else:
|
||||||
|
queue.append(0)
|
||||||
|
if(now_weight == 0):
|
||||||
|
break
|
||||||
|
return seconds
|
||||||
|
|
||||||
|
print(solution(2, 10, [7,4,5,6]))
|
||||||
23
백준/1016.Py
Normal file
23
백준/1016.Py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import math
|
||||||
|
import sys
|
||||||
|
|
||||||
|
input = sys.stdin.readline
|
||||||
|
|
||||||
|
min, max = map(int, input().split())
|
||||||
|
|
||||||
|
arr = [False] * (max-min+1)
|
||||||
|
|
||||||
|
for i in range(2, int(math.sqrt(max)+1)):
|
||||||
|
pow = i * i
|
||||||
|
start_index = int(min / pow) # 제곱수가 아닌 수 -> 제곱수는 무언가를 곱해서 만드는 수 ? 인걸로 이해했는데
|
||||||
|
if min % pow!=0:
|
||||||
|
start_index += 1
|
||||||
|
for j in range(start_index, int(max/pow)+1):
|
||||||
|
arr[int((j*pow) - min)] = True
|
||||||
|
|
||||||
|
count = 0
|
||||||
|
for i in range(0, max-min+1):
|
||||||
|
if arr[i] == False:
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
print(count)
|
||||||
Reference in New Issue
Block a user