정화 코딩

EDOC 2024-1 1회차 정모 본문

Group/EDOC

EDOC 2024-1 1회차 정모

jungh150c 2024. 3. 26. 02:46

A. 과제 안 내신 분..? (백준 5597번)

 

https://www.acmicpc.net/problem/5597

 

#python

from sys import stdin

task = [0 for i in range(0, 31)]

for _ in range(28):
    task[int(stdin.readline())] = 1

for i in range(1, 31):
    if task[i] == 0:
        print(i)

(정답)

 


 

B. 대출 요청 (백준 16497번)

 

https://www.acmicpc.net/problem/16497

 

#python

from sys import stdin

n = int(stdin.readline())
date = [0 for _ in range(32)]
isPossible = True

for _ in range(n):
    a, b = map(int, stdin.readline().split())
    for i in range(a, b):
        date[i] += 1

k = int(stdin.readline())

for i in range(1, 32):
    if date[i] > k:
        isPossible = False
        break

if isPossible:
    print(1)
else:
    print(0)

(정답)

 


 

C. 기념일 1 (백준 10420번)

 

 

#python

from sys import stdin

y = 2014
m = 4
d = 2
isLeapYear = False

n = int(stdin.readline())

while n // 366 != 0:
    n -= 365
    y += 1
    if ((y % 4 == 0) and (y % 100 != 0)) or (y % 400 == 0):
        n -= 1
        if m != 2:
            if ((m < 8) and (m % 2 == 1)) or ((m > 7) and (m % 2 == 0)):
                if d == 32:
                    m += 1
                    d = 1
            else:
                if d == 31:
                    m += 1
                    d = 1
        if m == 13:
            y += 1
            m = 1

if ((y % 4 == 0) and (y % 100 != 0)) or (y % 400 == 0):
    isLeapYear = True

while n != 1:
    n -= 1
    d += 1
    if m == 2:
        if isLeapYear:
            if d == 30:
                m += 1
                d = 1
        else:
            if d == 29:
                m += 1
                d = 1
    elif ((m < 8) and (m % 2 == 1)) or ((m > 7) and (m % 2 == 0)):
        if d == 32:
            m += 1
            d = 1
    else:
        if d == 31:
            m += 1
            d = 1
    if m == 13:
        y += 1
        m = 1
        if ((y % 4 == 0) and (y % 100 != 0)) or (y % 400 == 0):
            isLeapYear = True
        else:
            isLeapYear = False

print(str(y) + "-" + format(m, '02') + "-" + format(d, '02'))

진짜 이렇게 푸는 게 맞을까..?? 너무 if문이 많다 보니 뭘 자꾸 하나씩 실수해서 계속 틀리다가 겨우 맞혔다 ㅠㅠ (정답)

 

Comments