오늘부터 1일 1문제 도전!

오늘부터 이 글의 댓글로 백준 1일 1문제 도전해보겠습니다.

7 Likes

Sliver V
#1181번: 단어 정렬

Python 3(10/18)
N = int(input())
S = []
for i in range(N):
    s = input()
    S.append(s)

S = set(S)
S = list(S)

S.sort()
S.sort(key=len)

for i in S:
    print(i)
1 Like

:clap: 괴수들이 훈수 둬도, 쫄지 마시고, 반응이 없다고 실망 마세요. “꾸준히” 가 중요한거 같읍니다.

2 Likes

:thinking: :grinning:

1 Like

저도 하루에 하나씩 풀어보려고 했는데 어느날부터 며칠 째 안 풀고 있네요…
많이 하는것 보다 오래 하는게 더 중요한것 같습니다. ㅎㅇㅌ :fire:

1 Like

Silver V
#1064번: 평행사변형

Python 3(10/19)
xa, ya, xb, yb, xc, yc = map(int, input().split())

incliAB = [xa - xb, ya - yb]
incliAC = [xa - xc, xa - yc]

if (ya - yb) * (xa - xc) == (ya - yc) * (xa - xb):
    print(-1.0)
else:
    lenAB = ((xa - xb)**2 + (ya - yb)**2)**(1/2)
    lenAC = ((xa - xc)**2 + (ya - yc)**2)**(1/2)
    lenBC = ((xb - xc)**2 + (yb - yc)**2)**(1/2)
    longest = max(lenAB + lenAC, lenAB + lenBC, lenAC + lenBC)
    shortest = min(lenAB + lenAC, lenAB + lenBC, lenAC + lenBC)
    print((longest - shortest) * 2)

Silver V
#1010번: 다리 놓기

Python 3(10/20)
def factorial(n):
    f = 1
    for i in range(1, n + 1):
        f = f * i
    return f

def combination(r, n):
    return factorial(n) / (factorial(r) * factorial(n - r))

t = int(input())

for i in range(1, t + 1):
    n, m = map(int, input().split())
    print("%d" % combination(n, m))
1 Like

Silver V
#1380: 귀걸이

Python 3(10/21)
namelist = []
numberlist = []
count = 1
while 1:
    n = int(input())
    if n == 0:
        break
    for i in range(n):
        name = input()
        namelist.append(name)
    for i in range(2*n-1):
        number, x = input().split()
        number = int(number)
        if number in numberlist:
            numberlist.remove(number)
        else:
            numberlist.append(number)
    print(count, namelist[numberlist[0]-1])
    count += 1
    namelist.clear()
    numberlist.clear()
1 Like

Silver V
#1037: 약수

Python 3(10/22)
n = int(input())
a = list(map(int, input().split()))

ma = max(a)
mi = min(a)

print(ma * mi)

Silver V
#1769: 3의 배수

Python 3(10/23)
def multiple(X, count):
    if len(X) > 1:
        result = 0
        count += 1
        for i in X:
            result += int(i)
        multiple(str(result), count)
    else:
        if X in ['3', '6', '9']:
            print(count)
            print("YES")
        else:
            print(count)
            print("NO")


X = input()
multiple(X, 0)

Silver V
#1812: 사탕

Python 3(10/24)"
N = int(input())
numberlist = [int(input()) for _ in range(N)]
candylist = []
result = 0
for i in range(N):
    if i % 2 == 0:
        result += numberlist[i]
    else:
        result -= numberlist[i]
candylist.append(result // 2)

for i in range(N-1):
    candylist.append(numberlist[i] - candylist[i])
for i in candylist:
    print(i)

Silver V
#2204: 도비의 난독증 테스트

Python 3(10/25)
while 1:
    n = int(input())
    if n == 0:
        break
    wordlist = [input() for _ in range(n)]
    cheaklist = [wordlist[i].lower() for i in range(n)]
    cheakindex = wordlist[cheaklist.index(min(cheaklist))]
    print(cheakindex)
1 Like

Silver V
#2947번: 나무 조각

Python 3(10/26)
numberlist = list(map(int, input().split()))
cheaklist = [1, 2, 3, 4, 5]
while numberlist != cheaklist:
    for i in range(4):
        if numberlist[i] > numberlist[i+1]:
            temp = numberlist[i]
            numberlist[i] = numberlist[i+1]
            numberlist[i+1]= temp
            print(" ".join(map(str, numberlist)))
1 Like

Silver V
#1018번: 체스판 다시 칠하기

Python 3(10/27)
board = []
boardpart = []

N, M = map(int, input().split())
for _ in range(N):
    board.append(input())

result = 64
for i in range(N-7):
    for j in range(M-7):
        countBW = 0
        countWB = 0
        for y in range(i, i + 8):
            for x in range(j, j + 8):
                if (y + x) % 2 == 0:
                    if board[y][x] == 'B':
                        countBW += 1
                    if board[y][x] == 'W':
                        countWB += 1
                else:
                    if board[y][x] == 'W':
                        countBW += 1
                    if board[y][x] == 'B':
                        countWB += 1
        result = min(result, countBW, countWB)

print(result)

Silver V
#1058번: 좋은 구간

Python 3(10/28)
L = int(input())
S = list(input().split())
n = int(input())
route, start, last = 0, 0, 0


S = list(map(int, S))
S.sort()

for i in S:
    if i == n:
        start, last = i, i
        break
    elif i < n:
        start = i
    elif i > n:
        last = i
        break

if start == last:
    route = 0
else:
    route = (n - start) * (last - n - 1) + (n - start - 1)

print(route)

Silver V
#1094번: 막대기

Python 3(10/29)
x = int(input())
x = str(bin(x))[2:]
partNum = 0
for i in x:
    if i == '1':
        partNum+=1
print(partNum)
1 Like

Silver V
#1158번: 요세푸스 문제

Python 3(10/30)
N, K = map(int, input().split())
liA = [i for i in range(1, N + 1)]
liB = []
num = 0

for i in range(1, N + 1):
    num = ((num + K) - 1) % len(liA)
    liB.append(str(liA.pop(num)))

print("<%s>" % ", ".join(liB))
1 Like

Silver V
#1205번: 등수 구하기

Python 3(10/31)
N, NewScore, P = map(int, input().split())

if N == 0:
    print(1)
else:
    ScoreBoard = list(map(int, input().split()))
    ScoreBoard.append(NewScore)
    ScoreBoard.sort(reverse=True)
    rank = ScoreBoard.index(NewScore) + 1
    if rank > P:
        print(-1)
    elif N == P and NewScore == ScoreBoard[-1]:
        print(-1)
    else:
        print(rank)

Silver V
#1246번: 온라인 판매

Python 3(11/1)
N, M = map(int, input().split())
P = [int(input()) for _ in range(M)]
P.sort()
price = 0
most = 0
for i in range(M):
    if M - i < N:
        result = P[i] * (M - i)
    elif M - i >= N:
        result = P[i] * N
    if result > most:
        price = P[i]
        most = result
print(price, most)

Silver V
#1292번: 쉽게 푸는 문제

Python 3(11/2)
A, B = map(int, input().split())
arr = [i for i in range(46) for _ in range(i)]
print(sum(arr[A-1:B]))