본문 바로가기

백준1056

백준 26209 Intercepting Information https://www.acmicpc.net/problem/26209 26209번: Intercepting Information The input consists of a single line, containing $8$ integers $N_1$, $N_2$, $N_3$, $N_4$, $N_5$, $N_6$, $N_7$ and $N_8$, indicating the values read by the device ($N_i$ is 0, 1 or 9 for $1 ≤ i ≤ 8$). www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 def sol(nums): if 9 in nums : return False else: return True if __name__ == '__main__.. 2022. 12. 4.
백준 14625 냉동식품 https://www.acmicpc.net/problem/14625 14625번: 냉동식품 첫째 줄과 두 번째 줄에 시작시간과 종료시간이 시 H(0 ≤ H ≤ 23)와 분 M(0 ≤ M ≤ 59)이 정수로 빈칸을 사이에 두고 주어진다. 세 번째 줄에는 몇 분이 나오는지 알고 싶은 숫자 N(0 ≤ N ≤ 9)이 주 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 def sol(start_total, end_total, target): answer = 0 while str(start_total)!=str(end_total+1): str_hh = str(start_total//60) str_mm = str(start_tot.. 2022. 12. 3.
백준 5698 Tautogram https://www.acmicpc.net/problem/5698 5698번: Tautogram 선영이는 시를 매우 좋아한다. 최근에 선영이는 시집을 읽다가 매우 매력적인 시형을 찾았다. Tautogram은 매우 특별한 형태의 두운법으로, 인접한 단어가 같은 글자로 시작하는 것을 말한다. 문장 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 def sol(s): s=s.lower() s= list(s.split()) answer = 'Y' for i in range(1, len(s)): if s[i][0] != s[i-1][0]: answer = 'N' return answer if __name__ == '__main__': while True: s = inp.. 2022. 12. 3.
백준 21867 Java Bitecode https://www.acmicpc.net/problem/21867 21867번: Java Bitecode 첫째 줄에 코드의 길이를 나타내는 정수 $N$이 주어진다. ($1 \leq N \leq 200\,000$) 둘째 줄에 알파벳 대문자로 이루어진 코드 $S$가 주어진다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 def sol(s): to_be_changed = 'JAV' for alphabet in to_be_changed : s = s.replace(alphabet, '') if len(s) == 0: return 'nojava' else: return s if __name__ == '__main__': len_s = int(input()) s = in.. 2022. 12. 3.
백준 23627 driip https://www.acmicpc.net/problem/23627 23627번: driip 드립이가 생각하기에 주어진 문자열이 귀여우면 "cute", 그렇지 않으면 "not cute"를 출력한다. (따옴표 제외) www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 def sol(s): target = 'driip' if s.endswith(target) : return 'cute' else : return 'not cute' if __name__ == '__main__': s = input() print(sol(s)) cs endswith 함수를 사용하시면 쉽게 구현이 가능합니다. Use endswith function 2022. 12. 2.
백준 6246 풍선 놀이 https://www.acmicpc.net/problem/6246 6246번: 풍선 놀이 매년 가을 대전에서 열리는 대학생 프로그래밍 대회의 묘미 중 하나는 풍선 놀이이다. 시상식에서 스코어보드 공개를 기다리다가 심심해지면, 주위에 있는 풍선을 엮어서, 대회장을 가로지르는 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 def sol(n, q): balloons = [1]*(n+1) balloons[0] = 0 for _ in range(q): l, i = map(int, input().split()) for j in range(l, n+1, i): balloons[j] = 0 print(sum(balloons)) if __name__ == '__main__': n.. 2022. 12. 2.
백준 14914 사과와 바나나 나눠주기 https://www.acmicpc.net/problem/14914 14914번: 사과와 바나나 나눠주기 아름이가 나누어 줄 수 있는 경우를 모두 출력해야 하며, 각 경우마다 친구의 수, 사과 개수, 바나나 개수 차례로 한 줄에 각각 빈칸으로 구분하여 출력한다. 각 경우마다 중복없이 한 번만 출력 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 def sol(apple, banana): end = min(apple,banana) +1 for i in range(1, end): if apple%i == 0 and banana%i == 0 : print(i, apple//i, banana//i) if __name__ == '__main__': apple, banana = m.. 2022. 12. 2.
백준 11800 Tawla https://www.acmicpc.net/problem/11800 11800번: Tawla 각 테스트마다 상근이와 창영이가 외쳐야 할 문장을 "Case n:" ( "" 제외 ) 을 포함하여 출력하시오. 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 25 26 27 28 29 30 31 32 33 34 35 36 37 def sol(n): if n == 1: return 'Yakk' elif n == 2: return 'Doh' elif n == 3: return 'Seh' elif n == 4: return 'Ghar' elif n == 5: return 'Bang' elif n == 6: return 'Sh.. 2022. 12. 1.
백준 14614 Calculate! https://www.acmicpc.net/problem/14614 14614번: Calculate! 입력의 첫째 줄에 A, B, C가 공백으로 구분되어 주어진다. (1 ≤ A, B ≤ 108, 1 ≤ C ≤ 10100) www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 def sol(a, b, c): if c%2 == 1: return a^b else: return a if __name__ == '__main__': a, b, c = map(int, input().split()) print(sol(a, b, c)) Colored by Color Scripter cs https://sunchol21.tistory.com/1293 백준 12833 XORXORXOR https://www.ac.. 2022. 12. 1.
백준 3765 Celebrity jeopardy https://www.acmicpc.net/problem/3765 3765번: Celebrity jeopardy It’s hard to construct a problem that’s so easy that everyone will get it, yet still difficult enough to be worthy of some respect. Usually, we err on one side or the other. How simple can a problem really be? Here, as in Celebrity Jepoardy, questions www.acmicpc.net 1 2 3 4 5 6 7 if __name__ == '__main__': while True: try: s = input.. 2022. 11. 30.
백준 14954 Happy Number https://www.acmicpc.net/problem/14954 14954번: Happy Number Your program is to read from standard input. The input consists of a single line that contains an integer, n (1 ≤ n ≤ 1,000,000,000) www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 def sol(n): start_num = int(n) num_check =[] while True: check_num =0 for i in n: check_num+=int(i)**2 n = check_num if n == 1: return 'HAP.. 2022. 11. 30.
백준 12778 CTP공국으로 이민 가자 https://www.acmicpc.net/problem/12778 12778번: CTP공국으로 이민 가자 신생국가 CTP공국은 자신들만의 글자가 없다. CTP공국의 왕 준형이는 전 세계 표준 언어인 알파벳을 사용하기로 했다. 하지만 숫자에 미친 사람들이 모인 CTP공국 주민들은 알파벳을 사용할 때 평 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 def sol(type_prob, probs): if type_prob == 'C': answer = [ord(i)-64 for i in probs] elif type_prob == 'N': answer = [chr(int(i) + 64) for i in probs] return answer if __name__ .. 2022. 11. 30.