Skip to content

Commit 528dc55

Browse files
committed
Upload 1074, 9037, 16769
1 parent 01608c8 commit 528dc55

File tree

4 files changed

+178
-0
lines changed

4 files changed

+178
-0
lines changed

BAEKJOON/1074/README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# 백준 1074번 \_ Z
2+
3+
> 재귀를 써야할 것은 알았으나 어떻게 써야할지 감이 안잡혔음
4+
5+
## [문제 보기](https://www.acmicpc.net/problem/1074)
6+
7+
## 놓친 것
8+
9+
- 2차원 배열에 대한 이해
10+
- 재귀에 대한 이해
11+
12+
## 내가 짠 코드
13+
14+
```python
15+
16+
```
17+
18+
## 가장 적절한 코드
19+
20+
```python
21+
def Z(sz,x,y):
22+
if sz==1:
23+
return 0
24+
sz //=2
25+
for i in range(2):
26+
for j in range(2):
27+
if x < sz*(i+1) and y < sz*(j+1):
28+
return (i*2+j)*sz*sz + Z(sz, x-sz*i, y-sz*j)
29+
30+
31+
32+
N, r, c = map(int, input().split())
33+
34+
print(Z(2**N,r,c))
35+
```

BAEKJOON/16769/README.md

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# 백준 16769번 \_ Mixing Milk
2+
3+
> 시간을 줄일 수 있는 방법을 더 알아보자.
4+
5+
## [문제 보기](https://www.acmicpc.net/problem/16769)
6+
7+
## 놓친 것
8+
9+
- 한줄로 짜면 동시에 작업이 이루어짐
10+
- max(), min()
11+
- 함수로 따로 빼서 짜면 시간이 훨씬 많이 걸린다...(?)
12+
13+
## 내가 짠 코드
14+
15+
```python
16+
def pour(next_bt, current_m, next_m):
17+
if(current_m + next_m > next_bt):
18+
current_m = current_m + next_m - next_bt
19+
next_m = next_bt
20+
return current_m, next_m
21+
else:
22+
next_m = current_m + next_m
23+
current_m = 0
24+
return current_m, next_m
25+
26+
27+
bt1, m1 = map(int,input().split())
28+
bt2, m2 = map(int,input().split())
29+
bt3, m3 = map(int,input().split())
30+
31+
for i in range(33):
32+
m1, m2 = pour(bt2,m1,m2)
33+
m2, m3 = pour(bt3,m2,m3)
34+
m3, m1 = pour(bt1,m3,m1)
35+
36+
m1, m2 = pour(bt2,m1,m2)
37+
38+
print(m1)
39+
print(m2)
40+
print(m3)
41+
```
42+
43+
## 가장 적절한 코드
44+
45+
```python
46+
C, M = list(), list()
47+
for i in range(3):
48+
a,b = map(int, input().split())
49+
C.append(a)
50+
M.append(b)
51+
52+
for i in range(100):
53+
idx = i%3
54+
nxt = (idx+1) %3
55+
M[idx], M[nxt] = max(M[idx] -(C[nxt]-M[nxt]), 0), min(C[nxt], M[nxt]+M[idx])
56+
57+
for i in M:
58+
print(i)
59+
```

BAEKJOON/9037/README.md

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# 백준 9037번 \_ The candy war
2+
3+
> 왜 시간초과.. why..
4+
5+
## [문제 보기](https://www.acmicpc.net/problem/9037)
6+
7+
## 놓친 것
8+
9+
- 보이는 문제를 쪼개고 더 쪼개자(분할정복)
10+
- set을 하면 중복이 사라진다.
11+
- 플로우는 비슷함. but 내꺼는 시간초과
12+
13+
## 내가 짠 코드
14+
15+
```python
16+
def ev(data):
17+
if data%2:
18+
return int(data//2+1)
19+
else:
20+
return int(data//2)
21+
22+
N = int(input())
23+
24+
for i in range(N):
25+
count = 0
26+
fsh = 1
27+
cn = int(input())
28+
ci_update = list(map(int, input().split()))
29+
ci_half=ci_update
30+
31+
for j in range(cn):
32+
if ci_update[j]%2:
33+
ci_update[j] += 1
34+
35+
while fsh:
36+
if max(ci_update)== min(ci_update):
37+
print(count)
38+
fsh = 0
39+
for j in range(cn):
40+
ci_half[j] = ev(ci_update[j])
41+
for k in range(cn):
42+
ci_update[k] = ev(ci_update[k]) + ci_half[k-1]
43+
count += 1
44+
```
45+
46+
## 가장 적절한 코드
47+
48+
```python
49+
def check(N, candy):
50+
for i in range(N):
51+
if candy[i] %2 ==1:
52+
candy[i] += 1
53+
return len(set(candy)) ==1
54+
55+
def teacher(N, candy):
56+
tmp_lst = [0 for i in range(N)]
57+
for idx in range(N):
58+
if candy[idx] % 2:
59+
candy[idx] +=1
60+
candy[idx] //= 2
61+
tmp_lst[(idx+1)%N] = candy[idx]
62+
63+
for idx in range(N):
64+
candy[idx] += tmp_lst[idx]
65+
66+
return candy
67+
68+
69+
70+
def process():
71+
N, candy = int(input()), list(map(int,input().split()))
72+
cnt = 0
73+
while not check(N,candy):
74+
cnt += 1
75+
candy = teacher(N,candy)
76+
print(cnt)
77+
78+
79+
for i in range(int(input())):
80+
process()
81+
```

BAEKJOON/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
# 백준을 풀어보자
22

3+
- [1074번 Z](1074)
34
- [1920번 수찾기](1920)
5+
- [9037번 The candy war](9037)
46
- [10539번 수빈이와 수열](10539)
57
- [15969번 행복](15969)
68
- [16165번 걸그룹 마스터 준석이](16165)
9+
- [16769번 Mixing Milk](16769)
710
- [17224번 APC는 왜 서브태스크 대회가 되었을까?](17224)
811
- [17269번 이름궁합 테스트](17269)
912
- [17389번 보너스 점수](17389)

0 commit comments

Comments
 (0)