Algorithm/케로베로스
[🐉 백준 11단계] 브루트 포스
대인보우
2020. 12. 21. 14:43
반응형
백준 11단계
브루트 포스
2798
n, s = map(int, input().split())
l = list(map(int, input().split()))
m = 0
while l:
a = l.pop(0)
for i in range(len(l)-1):
for j in range(i+1, len(l)):
if a+l[i]+l[j] <= s and a+l[i]+l[j] > m:
m = a+l[i]+l[j]
print(m)
2231
n = int(input())
idx = 0
for i in range(1, n+1):
l = list(map(int, str(i)))
s = i + sum(l)
if n == s:
idx = i
break
print(idx)
7568
n = int(input())
d = []
answer = []
for _ in range(n):
a, b = map(int, input().split())
d.append((a,b))
for i in range(len(d)):
count = 1
for j in range(len(d)):
if d[i][0] < d[j][0] and d[i][1] < d[j][1]:
count += 1
answer.append(count)
for i in answer:
print(i, end=" ")
1018
# 실패..^^
y, x = map(int, input().split())
chess = []
for _ in range(y):
chess.append(list(input()))
count = []
x2 = 0
y2 = 0
while True:
c = 0
for i in range(y2, y2+8):
for j in range(x2, x2+8):
if chess[i][j-1] == 'B' and chess[i][j] == 'B':
c += 1
elif if chess[i][j-1] == 'W' and chess[i][j] == 'W':
count.append(c)
if x2+1+8 > x and y2+1+8 > y:
break
elif x2+1+8 <= x and y2+1+8 > y:
x2 += 1
elif x2+1+8 > x and y2+1+8 <= y:
y2 += 1
else:
x2 += 1
y2 += 1
print(count)
n, m = map(int, input().split())
l = []
mini = []
# 입력
for _ in range(n):
l.append(input())
# n는 y축, m은 x축
for a in range(n - 7):
for i in range(m - 7):
idx1 = 0
idx2 = 0
for b in range(a, a + 8):
for j in range(i, i + 8): # 8X8 범위를 B와 W로 번갈아가면서 검사
if (j + b)%2 == 0:
if l[b][j] != 'W': idx1 += 1
if l[b][j] != 'B': idx2 += 1
else :
if l[b][j] != 'B': idx1 += 1
if l[b][j] != 'W': idx2 += 1
mini.append(idx1) # W로 시작했을 때 칠해야 할 부분
mini.append(idx2) # B로 시작했을 때 칠해야 할 부분
print(min(mini))
1436
n = int(input())
cnt = 0
six_n = 666
while True:
if '666' in str(six_n):
cnt += 1
if cnt == n:
print(six_n)
break
six_n += 1
반응형