본문 바로가기

백준1056

백준 10988 팰린드롬인지 확인하기 https://www.acmicpc.net/problem/10988 10988번: 팰린드롬인지 확인하기 첫째 줄에 단어가 주어진다. 단어의 길이는 1보다 크거나 같고, 100보다 작거나 같으며, 알파벳 소문자로만 이루어져 있다. www.acmicpc.net 1 2 3 4 5 6 7 8 def sol(s): if s==s[::-1] : return 1 else : return 0 s=input() print(sol(s)) cs 이 문제는 문자열을 입력받고 그 문자열이 팰린드롬(앞으로 읽거나 거꾸로 읽어도 똑같은 문자열)인지 판단하는 문제 (This problem is a problem of receiving a string as input and determining whether the string is.. 2022. 10. 4.
백준 2999 비밀 이메일 https://www.acmicpc.net/problem/2999 2999번: 비밀 이메일 정인이는 원래 "bombonisuuladici"를 보내려고 했다. 이 메시지는 16글자이므로, 정인이는 1*16, 2*8, 4*4 행렬을 선택할 수 있다. R이 가장 큰 것은 4*4이므로, 4*4를 선택한다. 정인이가 만든 행렬은 다음과 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 def cal(n): r,c=0,0 for i in range(1, n): if n%i==0 and i 2022. 10. 3.
백준 baekjoon 2846 오르막길 https://www.acmicpc.net/problem/2846 2846번: 오르막길 상근이는 자전거를 타고 등교한다. 자전거 길은 오르막길, 내리막길, 평지로 이루어져 있다. 상근이는 개강 첫 날 자전거를 타고 가면서 일정 거리마다 높이를 측정했다. 상근이는 가장 큰 오르 www.acmicpc.net 이 문제는 정수를 입력받아서 그 정수들의 부분수열이 증가(단조증가 X)하는 경우에서 부분수열의 시작과 끝의 차이가 가장 큰 경우를 출력하는 문제입니다. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 def sol(n,nums): end=0 start = nums[0] for i in range(n-1): if nums[i] 2022. 9. 29.
백준 11005 진법 변환 2 https://www.acmicpc.net/problem/11005 11005번: 진법 변환 2 10진법 수 N이 주어진다. 이 수를 B진법으로 바꿔 출력하는 프로그램을 작성하시오. 10진법을 넘어가는 진법은 숫자로 표시할 수 없는 자리가 있다. 이런 경우에는 다음과 같이 알파벳 대문자를 www.acmicpc.net 이 문제는 특정 정수를 입력받으면 N진법으로 변환해서 출력하는 문제입니다. 크게 문제는 어려운게 없고 while문 구조상 나머지가 append되는 순서가 거꾸로 될 필요가 있습니다. ex)16을 2진법으로 저 예제처럼 돌린다고 가정하면 위 그림과 같겠죠? 우리는 1000 을 출력해야되는데 저 구조상은 0001이 되니까 reverse 시켜줍니다 그리고 for문에서 10이상인 경우 처리해줍니다... 2022. 9. 28.
백준 25183 인생은 한 방 https://www.acmicpc.net/problem/25183 25183번: 인생은 한 방 문자열 $S$의 부분 문자열이란, 문자열의 연속된 일부를 의미한다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 def check(s1,s2): if abs(ord(s1) - ord(s2))==1: return True else: return False def sol(n,s): cnt=1 for i in range(1,n): if cnt==5: return True if check(s[i],s[i-1]): cnt += 1 else : cnt = 1 if cnt == 5: return True else : retur.. 2022. 9. 27.
백준 25558 내비게이션 https://www.acmicpc.net/problem/25558 25558번: 내비게이션 1번 내비게이션이 안내한 경로는 $(0,0) \rightarrow (11,1) \rightarrow (9,9) \rightarrow (10,10)$으로, 총 거리는 $12 + 10 + 2 = 24$이다. 2번 내비게이션이 안내한 경로는 $(0,0) \rightarrow (1,12) \rightarrow (9,9) \ri www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 import sys def cal(a,b,c,d): return abs(c-a)+abs(d-b) n = int(sys.stdin.readline()) distance_list=[] s.. 2022. 9. 26.
백준 25576 찾았다 악질 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 pyimport sys n,m=map(int,sys.stdin.readline().split()) ral=list(map(int, sys.stdin.readline().split())) cnt=n-1 standard=0 for i in range(n-1): compare=list(map(int, sys.stdin.readline().split())) trend_sum=0 for j in range(m): trend_sum+=abs(ral[j]-compare[j]) if trend_sum > 2000: standard+=1 if standard>=cnt/2: print("YES") else : print("NO") Colored b.. 2022. 9. 24.
백준 25495 에어팟 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 def sol(nums): current_phone=nums[0] current_battery = 2 accumulate_cnt= 1 for i in range(1, len(nums)): if current_battery >= 100: current_phone = 0 current_battery = 0 accumulate_cnt = 1 if current_phone == nums[i]: accumulate_cnt += 1 current_battery += 2**accumulate_cnt else : accumulate_cnt = 1 current_battery +=2 current_.. 2022. 9. 22.
백준 25625 샤틀버스 1 2 3 4 5 6 7 def sol(num1,num2): if num1 > num2 : return num1+num2 else : return abs(num1-num2) num1,num2=map(int,input().split()) print(sol(num1,num2)) cs 이 문제는 코드 짜는게 어려운게 아닌데 예제1,2를 기준으로 설명드립니다. x는 서울대입구역에서 제2공학관까지의 거리와도 같습니다. 다만 버스는 y분 후에 제2공학관으로 도착할 예정이라고합니다. 즉 y의 경우는 서울대입구-> 제2공학관, 제2공학관 ->서울대입구역->제2공학관 이렇게 두가지가 있습니다 여기서 x가 y보다 큰경우(예제 1)는 버스가 '서울대입구역'에서 출발!해서 제2공학관을 찍고 다시 서울대입구로 내려와야합니다 따.. 2022. 9. 22.
백준 25591 푸앙이와 종윤이 1 2 3 4 5 6 7 8 9 10 11 12 13 def sol(num1, num2): a = 100 - num1 b = 100 - num2 c = 100 - (a+b) d = a*b q = d//100 r = d % 100 print(a, b, c, d, q, r) print(c+q, r) num1,num2= map(int,input().split()) sol(num1,num2) cs 이 문제는 정수를 입력받고 출력하는 문제입니다 인도? 수학? 나왔다고 해서 겁먹지 마시고 천천히 읽으면 쉽게 풀 수 있어요 2022. 9. 22.
백준 4435 중간계 전쟁 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 def cal_gan(nums): score=0 score_nums=[1,2,3,3,4,10] for i in range(len(nums)): score+=score_nums[i]*nums[i] return score def cal_sauron(nums): score=0 score_nums=[1,2,2,2,3,5,10] for i in range(len(nums)): score+=score_nums[i]*nums[i] return score n=int(input()) for i in range(n): nums_gan = list(map(int,input().split())) nums_sa.. 2022. 9. 21.
백준 11257 IT Passport Examination 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 def sol(student_number,st,it,tech): st_limit = 35 it_limit = 25 tech_limit = 40 result ='' if st+it+tech>=55 and st>=st_limit*0.3 and it>=it_limit*0.3 and tech>=tech_limit*0.3: result="PASS" else : result="FAIL" print("%d %d %s"%(student_number,st+it+tech,result)) n=int(input()) for i in range(n): student_number,st,it,tech=map(int,input().split()) sol(stude.. 2022. 9. 20.