We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent fe4a3e9 commit 24e2b92Copy full SHA for 24e2b92
Baekjoon/Q14888.py
@@ -0,0 +1,34 @@
1
+# link: https://www.acmicpc.net/problem/14888
2
+# 다시 풀어볼 것
3
+
4
+import sys
5
6
+input = sys.stdin.readline
7
+N = int(input())
8
+num = list(map(int, input().split()))
9
+op = list(map(int, input().split()))
10
11
+maximum = -1e9
12
+minimum = 1e9
13
14
15
+def dfs(depth, total, plus, minus, multiply, divide):
16
+ global maximum, minimum
17
+ if depth == N:
18
+ maximum = max(total, maximum)
19
+ minimum = min(total, minimum)
20
+ return
21
22
+ if plus:
23
+ dfs(depth + 1, total + num[depth], plus - 1, minus, multiply, divide)
24
+ if minus:
25
+ dfs(depth + 1, total - num[depth], plus, minus - 1, multiply, divide)
26
+ if multiply:
27
+ dfs(depth + 1, total * num[depth], plus, minus, multiply - 1, divide)
28
+ if divide:
29
+ dfs(depth + 1, int(total / num[depth]), plus, minus, multiply, divide - 1)
30
31
32
+dfs(1, num[0], op[0], op[1], op[2], op[3])
33
+print(maximum)
34
+print(minimum)
Baekjoon/Q14891.py
@@ -0,0 +1,63 @@
+# link: https://www.acmicpc.net/problem/14891
+# 다시 풀어보자..
+from collections import deque
+def rotate(a,array):
+ temp = [0]*8
+ if a == -1: #반시계방향
+ temp[7] = array[0]
+ for i in range(1,len(array)):
+ temp[i-1] = array[i]
+ if a == 1: #시계방향
+ temp[0] = array[7]
+ for i in range(len(array)-1):
+ temp[i+1] = array[i]
+ return temp
+score = [1,2,4,8]
+topni = []
+for _ in range(4):
+ topni.append(list(map(int,input())))
+k = int(input())
+def check(a,dir):
+ rotate_list = []
+ visitied = [False]*4
+ queue = deque()
+ queue.append((a-1,dir))
+ visitied[a-1] = True
+ rotate_list.append((a-1,dir))
+ while queue:
35
+ x,dir = queue.popleft()
36
+ #왼쪽톱니바퀴와 맞닿을때
37
+ nx = x-1
38
+ if (0<=nx<4 and topni[nx][2] != topni[x][6] and not visitied[nx]):
39
+ queue.append((nx,-dir))
40
+ rotate_list.append((nx,-dir))
41
+ visitied[nx] = True
42
+ #오른쪽 톱니바퀴와 맞닿을때
43
+ nx = x+1
44
+ if(0<=nx<4 and topni[nx][6] != topni[x][2] and not visitied[nx]):
45
46
47
48
+ return rotate_list
49
50
+for _ in range(k):
51
+ number,direc = map(int,input().split())
52
+ rotate_list= check(number,direc)
53
+ for i,j in rotate_list:
54
+ topni[i] = rotate(j,topni[i])
55
56
57
+sum = 0
58
+for i in range(len(topni)):
59
+ if topni[i][0] == 0:
60
+ sum+=0
61
+ if topni[i][0] == 1:
62
+ sum+=score[i]
63
+print(sum)
Baekjoon/Q18870.py
@@ -0,0 +1,13 @@
+# link: https://www.acmicpc.net/problem/18870
+n = int(input())
+nums = list(map(int, input().split()))
+sortedNums = sorted(list(set(nums)))
+numDic = {sortedNums[i]: i for i in range(len(sortedNums))}
+for num in nums:
+ print(numDic[num], end=' ')
0 commit comments