백준 5671 호텔 방 번호
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 while 1: cnt=0 try: a,b=map(int, input().split()) for i in range(a,b+1): tmp=['0','1','2','3','4','5','6','7','8','9'] tmp2=[0]*10 i=str(i) for j in i: tmp2[int(j)]+=1 flagDuplicate=0 for j in tmp2: if j>1:flagDuplicate=1 if flagDuplicate==0 : cnt+=1 print(cnt) except : break Colored by Color Scripter cs
2021. 12. 6.
백준 5635 생일
1 2 3 4 5 6 7 8 9 10 tmp=[] for i in range(int(input())): name,dd,mm,yy=input().split() dd=int(dd) mm = int(mm) yy= int(yy) tmp.append([name,yy,mm,dd]) tmp=sorted(tmp, key=lambda x: (x[1], x[2], x[3])) print(tmp[-1][0]) print(tmp[0][0]) Colored by Color Scripter cs sort는 lambda를 통해서 하시면되고 주의할만한건 생년 월 일 을 각각 type casting해주셔야합니다. 그냥 input()으로 받으면 기본 type이 str이라서 순서가 다르게 (1 , 10 ,11, 12 ,2, 3,4, ....
2021. 12. 6.