분류 전체보기
-
[python]백준 8진수, 10진수, 16진수 11816번알고리즘 문제풀이/백준(파이썬) 2023. 6. 22. 20:51
import sys sys.stdin = open("11816.txt", "r") x=input() if x[:2]=="0x":#16진수 print(int(x,16)) sys.exit(0)#종료 elif x[0]=="0":#8진수 print(int(x,8)) else:#10진수 print(int(x)) 코드 링크 https://www.acmicpc.net/problem/11816 11816번: 8진수, 10진수, 16진수 첫째 줄에 X가 주어진다. X는 10진수로 바꿨을 때, 1,000,000보다 작거나 같은 자연수이다. 16진수인 경우 알파벳은 소문자로만 이루어져 있다. www.acmicpc.net
-
[python]백준 책 정리 1434번알고리즘 문제풀이/백준(파이썬) 2023. 6. 21. 23:39
코드 import sys sys.stdin = open("1434.txt", "r") a,b=map(int,input().split()) q=list(map(int,input().split())) w=list(map(int,input().split())) print(sum(q)-sum(w)) 링크 https://www.acmicpc.net/problem/1434 1434번: 책 정리 첫째 줄에 박스의 개수 N, 책의 개수 M이 주어진다. 둘째 줄에는 박스의 용량 A1, A2, ..., AN이 주어지고, 셋째 줄에는 B1, B2, ..., BM이 주어진다. www.acmicpc.net
-
[python]백준 얼마? 9325번알고리즘 문제풀이/백준(파이썬) 2023. 6. 20. 22:37
코드 import sys sys.stdin = open("9325.txt", "r") t=int(input()) s=0 for _ in range(t): s=int(input()) q=int(input())#서로다른 옵션 개수 for i in range(q): a,b=map(int,input().split()) s+=a*b print(s) 링크 https://www.acmicpc.net/problem/9325 9325번: 얼마? 해빈이는 학교를 다니면서 틈틈히 번 돈으로 자동차를 사려고 한다. 자동차에 여러 가지 옵션을 포함시킬 수 있는데 해빈이는 덧셈과 곱셈을 하지 못하기 때문에 친구 태완이에게 도움을 청했 www.acmicpc.net
-
[python]백준 배고파(Easy) 28239번알고리즘 문제풀이/백준(파이썬) 2023. 6. 19. 23:27
코드 import sys import math sys.stdin = open("28239.txt", "r") t=int(input()) for i in range(t): q=int(input()) w = int(math.log2(q)) for i in range(w + 1): for j in range(i, w + 1):#0~w+1 # 처음 2^0 2^0 if 2**i + 2**j == q: print(i,j) 링크 https://www.acmicpc.net/problem/28239 28239번: 배고파(Easy) $n$개의 줄에 각각 주문할 메뉴의 위치 $(x,y)$의 $x$, $y$를 공백으로 구분하여 출력한다. www.acmicpc.net
-
[python]백준 코드마스터 2023 28235번알고리즘 문제풀이/백준(파이썬) 2023. 6. 18. 23:43
코드 import sys sys.stdin = open("28235.txt", "r") q=input() if 'SONGDO'==q: print("HIGHSCHOOL") if 'CODE'==q: print("MASTER") if '2023'==q: print("0611") if 'ALGORITHM'==q: print("CONTEST") 링크 https://www.acmicpc.net/problem/28235 28235번: 코드마스터 2023 송도고등학교에서 주최하는 첫 중고등학생 대상 알고리즘 대회, "코드마스터 2023"이 열렸다! 이 대회가 중고등학생들에게 인기 있는 알고리즘 대회이자 오프라인 이벤트로서 자리매김할 수 있 www.acmicpc.net
-
[python]백준 조합 0의 개수 2004번알고리즘 문제풀이/백준(파이썬) 2023. 6. 17. 23:54
코드 import sys sys.stdin = open("2004.txt", "r") a,b=map(int, input().split()) def test(a,b): s=0 while a>=b: s+=a//b a//=b return s#test()에서 b인자가 크다 s 리턴 s_2=test(a,2)-test(b,2)-test(a-b,2) s_5=test(a,5)-test(b,5)-test(a-b,5) print(min(s_2,s_5)) 링크 https://www.acmicpc.net/problem/2004 2004번: 조합 0의 개수 첫째 줄에 정수 $n$, $m$ ($0 \le m \le n \le 2,000,000,000$, $n \ne 0$)이 들어온다. www.acmicpc.net
-
[python]백준 Who is in the middle? 6840번알고리즘 문제풀이/백준(파이썬) 2023. 6. 16. 23:58
코드 import sys sys.stdin = open("6840.txt", "r") q=[] for i in range(3): q.append(int(input())) q.sort() print(q[1]) 링크 https://www.acmicpc.net/problem/6840 6840번: Who is in the middle? In the story Goldilocks and the Three Bears, each bear had a bowl of porridge to eat while sitting at his/her favourite chair. What the story didn’t tell us is that Goldilocks moved the bowls around on the table, ..