백준(Python) 풀이/수학 213

백준(Python) 2869번 달팽이는 올라가고 싶다 풀이

Python으로 구현한 2869번 달팽이는 올라가고 싶다 문제 풀이입니다. https://www.acmicpc.net/problem/2869 2869번: 달팽이는 올라가고 싶다 첫째 줄에 세 정수 A, B, V가 공백으로 구분되어서 주어진다. (1 ≤ B < A ≤ V ≤ 1,000,000,000) www.acmicpc.net a, b, v = map(int, input().split()) value = (v - b) / (a - b) if int(value) == value : value = int(value) else : value = int(value) + 1 print(value) 1. 달팽이가 올라갔다 다시 미끄러지는 과정에서 실질적으로 올라갈 수 있는 거리(ex. 3미터 올라가고, 1미터 떨어..

백준(Python) 1016번 제곱 ㄴㄴ 수 풀이

Python으로 구현한 1016번 제곱 ㄴㄴ 수 문제 풀이입니다. https://www.acmicpc.net/problem/1016 1016번: 제곱 ㄴㄴ 수 어떤 정수 X가 1보다 큰 제곱수로 나누어 떨어지지 않을 때, 그 수를 제곱ㄴㄴ수라고 한다. 제곱수는 정수의 제곱이다. min과 max가 주어지면, min보다 크거나 같고, max보다 작거나 같은 제곱ㄴㄴ수 www.acmicpc.net min_in, max_in = map(int, input().split()) size = max_in - min_in + 1 visited = [False] * size i = 2 while i * i

백준(Python) 15711번 환상의 짝꿍 풀이

Python으로 구현한 15711번 환상의 짝꿍 문제 풀이입니다. https://www.acmicpc.net/problem/15711 15711번: 환상의 짝꿍 환상의 나라 디디랜드에서는 인연의 증표로 끈을 하나씩 가지고 있다. 그들은 지극히 평범한 방법으로 이 끈을 이용하여 어떤 두 사람이 환상의 짝꿍인지 판단하는데, 두 사람의 끈을 서로 이 www.acmicpc.net def is_prime(value) : if value > max_value : for prime in primes : if prime >= value : break elif value % prime == 0 : return False return True else : return data[value] max_value = 200000..

백준(Python) 1644번 소수의 연속합 풀이

Python으로 구현한 1644번 소수의 연속합 문제 풀이입니다. https://www.acmicpc.net/problem/1644 1644번: 소수의 연속합 첫째 줄에 자연수 N이 주어진다. (1 ≤ N ≤ 4,000,000) www.acmicpc.net n = int(input()) is_prime = [False, False] + [True] * (n - 1) prime_list = [] for i in range(2, n + 1) : if is_prime[i] : prime_list.append(i) for j in range(i+i, n + 1, i) : is_prime[j] = False result = 0 start = 0 end = 0 while end

백준(Python) 2485번 가로수 풀이

Python으로 구현한 2485번 가로수 문제 풀이입니다. https://www.acmicpc.net/problem/2485 2485번: 가로수 첫째 줄에는 이미 심어져 있는 가로수의 수를 나타내는 하나의 정수 N이 주어진다(3 ≤ N ≤ 100,000). 둘째 줄부터 N개의 줄에는 각 줄마다 심어져 있는 가로수의 위치가 양의 정수로 주어지며, 가 www.acmicpc.net import math n = int(input()) data = [] diff_list = [] a = int(input()) # 첫번째 가로수 위치 data.append(a) for _ in range(n - 1) : value = int(input()) data.append(value) diff_list.append(value ..

백준(Python) 6603번 로또 풀이

Python으로 구현한 6603번 로또 문제 풀이입니다. https://www.acmicpc.net/problem/6603 6603번: 로또 입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스는 한 줄로 이루어져 있다. 첫 번째 수는 k (6 < k < 13)이고, 다음 k개 수는 집합 S에 포함되는 수이다. S의 원소는 오름차순으로 www.acmicpc.net from itertools import combinations while True : try : data = list(map(int, input().split())) if data[0] == 0 and len(data) == 1 : break del data[0] result = [] for combi in combinations..

백준(Python) 4375번 1 풀이

Python으로 구현한 4375번 1 문제 풀이입니다. https://www.acmicpc.net/problem/4375 4375번: 1 2와 5로 나누어 떨어지지 않는 정수 n(1 ≤ n ≤ 10000)가 주어졌을 때, 1로만 이루어진 n의 배수를 찾는 프로그램을 작성하시오. www.acmicpc.net while True : try : n = int(input()) value = '1' while True : if int(value) % n == 0 : print(len(value)) break value += '1' except EOFError : break 1. 여러 개의 테스트 케이스로 이루어지므로 try ~ except 를 통해 코드를 작성한다. 2. 처음 value 값은 '1'로 초기화 해준..

백준(Python) 22193번 Multiply 풀이

Python으로 구현한 22193번 Multiply 문제 풀이입니다. https://www.acmicpc.net/problem/22193 22193번: Multiply Write a program that computes a product of two non-negative integers A and B. The integers are represented in decimal notation and have N and M digits, respectively. www.acmicpc.net n, m = map(int, input().split()) a = int(input()) b = int(input()) print(a * b) 1. 입력받은 두 수(a, b)의 곱을 구하여 출력한다.

백준(Python) 6749번 Next in line 풀이

Python으로 구현한 6749번 수강변경 문제 풀이입니다. https://www.acmicpc.net/problem/6749 6749번: Next in line You know a family with three children. Their ages form an arithmetic sequence: the difference in ages between the middle child and youngest child is the same as the difference in ages between the oldest child and the middle child. For example, their ages c www.acmicpc.net y = int(input()) m = int(input()) ..

백준(Python) 11104번 Fridge of Your Dreams 풀이

Python으로 구현한 11104번 Fridge of Your Dreams 문제 풀이입니다. https://www.acmicpc.net/problem/11104 11104번: Fridge of Your Dreams Eirik drinks a lot of Bingo Cola to help him program faster, and over the years he has burned many unnecessary calories walking all the way to the kitchen to get some. To avoid this he has just bought a small fridge, which is beautifully placed next to his www.acmicpc.net t = i..