알고리즘 문제풀이/백준(파이썬)
-
[python]백준 화성 수학 5355번알고리즘 문제풀이/백준(파이썬) 2023. 5. 1. 19:54
코드 import sys sys.stdin = open("5355.txt", "r") t=int(input()) s=0.0 for _ in range(t):#t 반복 q=list(map(str,input().split()))#테스트 케이스 리스트 받아서 len만큼 반복하고 s=float(q[0]) for i in range(1,len(q)): if q[i]=="@": s*=3 elif q[i] =="%": s+=5 elif q[i] =="#": s-=7 print("%0.2f"%s)#계산하고 값출력 #출력 값 소수점 2번째 까지 #t 반복 # 테스트 케이스 리스트 받아서 len만큼 반복하고 # 계산하고 값출력 링크 https://www.acmicpc.net/problem/5355 5355번: 화성 수학 ..
-
[python]백준 진짜 공간 1350번알고리즘 문제풀이/백준(파이썬) 2023. 4. 30. 23:30
코드 import sys sys.stdin = open("1350.txt", "r") n=int(input()) f=list(map(int,input().split())) c=int(input()) s=0 for i in f: if i%c==0:#0 s+=i//c#0 #파일의 크기가 0같다면 클러스터 필요가 없다 else: s+=i//c+1 #파일의 크기가 0이아니면+1 #몫 소수점이면 +1 #몫 정수이면(1이상)i//c 실제 2 예1)600 512 #클러스터 크기가 파일의 크기 보다 작다면 추가 print(s*c) #파일의 크기가 0같다면 클러스터 필요가 없다 #클러스터 크기가 파일의 크기 보다 작다면 추가 링크 https://www.acmicpc.net/problem/1350 1350번: 진짜 공간 ..
-
[python]백준 파티가 끝나고 난 뒤 2845번알고리즘 문제풀이/백준(파이썬) 2023. 4. 29. 17:34
코드 import sys sys.stdin = open("2845.txt", "r") a,b=map(int,input().split()) c=list(map(int,input().split())) for i in range(len(c)): print(c[i]-(a*b),end=" ") 링크 https://www.acmicpc.net/problem/2845 2845번: 파티가 끝나고 난 뒤 파티가 끝나고 나면, 사람들은 누가 파티에 왔는지와 얼마나 많은 사람들이 왔는지를 궁금해한다. 보통 파티는 매우 크게 열리기 때문에, 정확하게 몇 명이 참가했는지 알 수가 없다. 지난주 토 www.acmicpc.net
-
[python]백준 당신은 운명을 믿나요? 27930번알고리즘 문제풀이/백준(파이썬) 2023. 4. 28. 22:14
코드 import sys sys.stdin = open("27930.txt", "r") s=list(input()) KOREA=["K" ,"O" ,"R" ,"E" ,"A"] YONSEI=["Y" ,"O" ,"N" ,"S" ,"E" ,"I"] for i in s: if i in KOREA: KOREA.remove(i) if len(KOREA)==0: print("KOREA") break if i in YONSEI: YONSEI.remove(i) if len(YONSEI)==0: print("YONSEI") break 링크 https://www.acmicpc.net/problem/27930 27930번: 당신은 운명을 믿나요? 민지는 11번째 글자까지 읽었을 때 각각 1,3,5,7,9번째의 글자를 제거하고 ..
-
[python]백준 10부제 10797번알고리즘 문제풀이/백준(파이썬) 2023. 4. 28. 22:10
코드 import sys sys.stdin = open("10797.txt", "r") q=int(input()) w=list(map(int,input().split())) s=0 for i in range(5): if q == w[i]: s+=1 print(s) #q가 w요소와 같다 +1 링크 https://www.acmicpc.net/problem/10797 10797번: 10부제 서울시는 6월 1일부터 교통 혼잡을 막기 위해서 자동차 10부제를 시행한다. 자동차 10부제는 자동차 번호의 일의 자리 숫자와 날짜의 일의 자리 숫자가 일치하면 해당 자동차의 운행을 금지하는 www.acmicpc.net
-
[python]백준 초코바 27959번알고리즘 문제풀이/백준(파이썬) 2023. 4. 27. 23:47
코드 import sys sys.stdin = open("27959.txt", "r") a,b=map(int,input().split()) if (a*100)>=b: print("Yes") else: print("No") 링크 https://www.acmicpc.net/problem/27959 27959번: 초코바 밤고는 $100$원 동전을 $N$개 갖고 있고, 그 돈으로 가격이 $M$원인 초코바를 사 먹으려고 한다. 밤고는 갖고 있는 돈으로 초코바를 사 먹을 수 있는지 알고 싶어 한다. 밤고가 가진 돈이 초코바의 www.acmicpc.net
-
[python]백준 특별한 학교 이름 27889번알고리즘 문제풀이/백준(파이썬) 2023. 4. 26. 23:30
코드 import sys sys.stdin = open("27889.txt", "r") q=input() if q=="NLCS": print("North London Collegiate School") elif q=="BHA": print("Branksome Hall Asia") elif q=="KIS": print("Korea International School") else: print("St. Johnsbury Academy") 링크 https://www.acmicpc.net/problem/27889 27889번: 특별한 학교 이름 GEC에는 여러 학교가 있다. 각 학교의 약칭과 정식 명칭은 다음과 같다. NLCS: North London Collegiate School BHA: Branksome ..
-
[python]백준 가위 바위 보? 4493번알고리즘 문제풀이/백준(파이썬) 2023. 4. 25. 22:04
코드 import sys sys.stdin = open("4493.txt", "r") t=int(input()) for i in range(t): s=int(input())#가위 바위 보를 한 횟수 #R바위 P보 S가위 s1=0 s2=0 for j in range(s): a,b= map(str,input().split()) if (a=="R" and b=="S")or(a=="P" and b=="R")or(a=="S" and b=="P"):#Player 1 승자이면 +1 s1+=1 elif (b=="R" and a=="S")or(b=="P" and a=="R")or(b=="S" and a=="P"):#Player 2 승자이면 +1 s2+=1 if s1>s2: print("Player 1") elif s1