본문 바로가기

백준1064

백준 24116 알고리즘 수업 - 피보나치 수 1 1 2 3 4 5 6 7 8 9 10 11 12 def fib(n): f=[[0,1],[1,0]] for i in range(2,n): f.append([f[i-1][0] + f[i-1][1] ,f[i-1][0] ] ) return sum(f[-1]) def fibonacci(n) : f=[0,1,1] for i in range(3,n+1): f.append( f[i - 1] + f[i - 2]) # 코드2 return f[n] n=int(input()) print(fib(n),n-2) Colored by Color Scripter cs 2022. 2. 7.
백준 2755 이번학기 평점은 몇점? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 from math import floor scores={'A+': 4.3, 'A0': 4.0, 'A-': 3.7, 'B+': 3.3, 'B0': 3.0, 'B-': 2.7, 'C+': 2.3, 'C0': 2.0, 'C-': 1.7, 'D+': 1.3, 'D0': 1.0, 'D-': 0.7, 'F': 0.0} n=int(input()) ans=0 sumScore=0 for i in range(n): name,score,grade=input().split() sumScore+=int(score) ans+=int(score)*scores[grade] tmpScore=(ans/sumScore)*1000 if tmpScor.. 2022. 1. 28.
백준 4562 No Brainer 1 2 3 4 5 n=int(input()) for i in range(n): a,b=map(int, input().split()) if a 2022. 1. 27.
백준 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.
백준 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.