SWEA

[python][SWEA][D1] 2056. 연월일 달력

haju 2023. 5. 4. 10:52

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=1&contestProbId=AV5QLkdKAz4DFAUq&categoryId=AV5QLkdKAz4DFAUq&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=1&pageSize=10&pageIndex=1 

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com

 

T=int(input())

for test_case in range(1,T+1):

    n=input()
    date=int(n[-2:])
    mon=int(n[-4:-2])
    year=int(n[:4])

    if mon>=1 and mon<=12:
        if mon%2!=0:
            if date>=1 and date<=31:
                print("#%d %04d/%02d/%02d" %(test_case,year,mon,date))
            else:
                print("#%d -1" % test_case)
        else: # 달이 짝수일 때,
            if mon==2:
                if date>=1 and date<=28:
                    print("#%d %04d/%02d/%02d" % (test_case, year, mon, date))
                else:
                    print("#%d -1" % test_case)
            else:
                if date>=1 and date<=30:
                    print("#%d %04d/%02d/%02d" % (test_case, year, mon, date))
                else:
                    print("#%d -1" % test_case)
    else:
        print("#%d -1" % test_case)