python-algorithm1422 백준 11367 Report Card Time 1 2 3 4 5 6 7 8 9 10 11 12 13 14 for i in range(int(input())): name,score=input().split() score=int(score) if score>=97 :grade='A+' elif score>=90 :grade='A' elif score >= 87: grade = 'B+' elif score >= 80: grade = 'B' elif score >= 77: grade = 'C+' elif score >= 70: grade = 'C' elif score >= 67: grade = 'D+' elif score >= 60: grade = 'D' else : grade = 'F' print(name,grade) Colored by Color Scr.. 2022. 1. 19. 백준 11944 NN 1 2 3 4 5 6 7 8 n,m=input().split() m=int(m) answer='' flag=0 for i in range(int(n)): if len(answer)>m : print(answer[:m]);flag=1;break answer+=n if flag==0 : print(answer) cs 2022. 1. 19. 백준 2857 FBI 1 2 3 4 5 6 fbiIndex=[] fbiList=[input() for i in range(5)] for i in range(len(fbiList)) : if 'FBI' in fbiList[i] : fbiIndex.append(i+1) if len(fbiIndex)>0: print(*fbiIndex) else : print("HE GOT AWAY!") cs 2022. 1. 19. 백준 2902 KMP는 왜 KMP일까? 1 2 3 4 5 s=list(input().split('-')) answer='' for i in s: answer+=i[0] print(answer) cs 2022. 1. 19. 백준 4597 패리티 1 2 3 4 5 6 7 8 9 10 11 while 1: s=input() if s=='#':break oneCount=s.count('1') if 'e' in s: if oneCount%2==0: s=s.replace('e','0') else :s=s.replace('e','1') elif 'o' in s: if oneCount%2==0: s=s.replace('o','1') else :s=s.replace('o','0') print(s) Colored by Color Scripter cs 2022. 1. 19. 백준 3183 Dates 1 2 3 4 5 6 7 8 import datetime while 1: d,m,y=map(int,input().split()) if d==0 and m==0 and y==0 :break try: datetime.date(y,m,d) print("Valid") except : print("Invalid") cs 2022. 1. 19. 백준 2948 2009년 1 2 3 4 import datetime days=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"] d,m=map(int,input().split()) print(days[(datetime.date(2009,m,d)).weekday()]) cs 2022. 1. 19. 백준 없는 숫자 더하기 1 2 3 def solution(numbers): answer = 45-sum(numbers) return answer cs 이런 문제에서 numbers 하나하나 뒤지면서 없는 숫자를 따로 찾는 방식으로 접근하게되면 입력이 많을경우 Timeout 생길수도 있거든요 Ad-hoc, heuristic한 기법 으로 0~9까지의 합이 45 라는 사실을 알고 있으면 45에서 numbers의 합한값을 빼면 없는 숫자들의 합이 나오겠죵 그러면 여기에서 선생님~ 이런 방식은 어떻게 떠오르는 건가요? 라고 하시면 반복학습이 답입니다. 알고리즘 문제도 수능문제 처럼 반복학습 하면 되는거같아요 2022. 1. 16. 백준 16199 나이 계산하기 1 2 3 4 5 6 7 8 9 10 11 12 birthYear,birthMonth,birthDay=map(int,input().split()) currentYear, currentMonth, currentDay = map(int, input().split()) if currentMonth>birthMonth : ageFirst=currentYear-birthYear elif currentMonth=birthDay : ageFirst= currentYear-birthYear else: ageFirst=currentYear-birthYear-1 ageSecond= currentYear-birthYear +1 ageThird=currentYear-birthYear print(ageFirst) print(a.. 2022. 1. 14. 백준 15651 N과 M (3) 1 2 3 4 5 6 7 8 9 10 11 12 n,m=map(int,input().split()) s=[] def dfs(): if len(s)==m: tmp=(" ".join(map(str, s))) print(tmp) return for i in range(1,n+1): s.append(i) dfs() s.pop() dfs() cs 2022. 1. 10. 백준 15650 N과 M (2) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 n,m=map(int,input().split()) s=[] ans=[] def dfs(): if len(s)==m: tmpAns=sorted((map(int,s))) if tmpAns not in ans :ans.append(tmpAns) return for i in range(1, n+1): if i not in s: s.append(i) dfs() s.pop() dfs() for i in ans: print(*i) Colored by Color Scripter cs 2022. 1. 10. 백준 15649 N과 M (1) 1 2 3 4 5 from itertools import permutations n,m =map(int,input().split()) p=permutations(range(1,n+1),m) for i in p: print(" ".join(map(str,i))) cs 2022. 1. 10. 이전 1 ··· 53 54 55 56 57 58 59 ··· 119 다음