수학 282

백준(JAVA) 2558번 A+B - 2 풀이

Java로 구현한 2558번 A+B - 2 문제 풀이입니다. https://www.acmicpc.net/problem/2558 2558번: A+B - 2 첫째 줄에 A, 둘째 줄에 B가 주어진다. (0 < A, B < 10) www.acmicpc.net import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); System.out.println(a + b); } } 1. 두 정수 a와 b를 입력받은 후 a + b를 출력한다.

백준(JAVA) 1000번 A+B 풀이

Java로 구현한 1000번 A+B 문제 풀이입니다. https://www.acmicpc.net/problem/1000 1000번: A+B 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. www.acmicpc.net import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); System.out.println(a + b); } } 1. 두 정수 a와 b를 입력받은 후 두 값을 더한 결과를 출력한다.

백준(Python) 2225번 합분해 풀이

Python으로 구현한 2225번 합분해 문제 풀이입니다. https://www.acmicpc.net/problem/2225 2225번: 합분해 첫째 줄에 답을 1,000,000,000으로 나눈 나머지를 출력한다. www.acmicpc.net import sys input = sys.stdin.readline n, k = map(int, input().split()) dp = [[0] * 201 for _ in range(201)] for i in range(201) : dp[1][i] = 1 dp[2][i] = i + 1 for i in range(2, 201) : dp[i][1] = i for j in range(2, 201) : dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % ..

백준(Python) 9461번 파도반 수열 풀이

Python으로 구현한 9461번 파도반 수열 문제 풀이입니다. https://www.acmicpc.net/problem/9461 9461번: 파도반 수열 오른쪽 그림과 같이 삼각형이 나선 모양으로 놓여져 있다. 첫 삼각형은 정삼각형으로 변의 길이는 1이다. 그 다음에는 다음과 같은 과정으로 정삼각형을 계속 추가한다. 나선에서 가장 긴 변의 www.acmicpc.net t = int(input()) dp = [0] * 101 for _ in range(t) : n = int(input()) def solution(n) : if n == 1 or n == 2 or n == 3 : return 1 if dp[n] != 0 : return dp[n] dp[n] = solution(n-2) + solution(..

백준(Python) 1699번 제곱수의 합 풀이

Python으로 구현한 1699번 제곱수의 합 문제 풀이입니다. https://www.acmicpc.net/problem/1699 1699번: 제곱수의 합 어떤 자연수 N은 그보다 작거나 같은 제곱수들의 합으로 나타낼 수 있다. 예를 들어 11=32+12+12(3개 항)이다. 이런 표현방법은 여러 가지가 될 수 있는데, 11의 경우 11=22+22+12+12+12(5개 항)도 가능하다 www.acmicpc.net import sys input = sys.stdin.readline n = int(input()) dp = [i for i in range(n + 1)] for i in range(1, n + 1) : for j in range(1, i) : if j**2 > i : break if dp[i] ..

백준(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) 3135번 라디오 풀이

Python으로 구현한 3135번 라디오 문제 풀이입니다. https://www.acmicpc.net/problem/3135 3135번: 라디오 첫 줄엔 정수 A와 B가 주어진다 (1 ≤ A, B < 1000, A ≠ B). 다음 줄엔 정수 N이 주어진다 (1 ≤ N ≤ 5). 다음 N개의 줄엔 미리 지정되어 있는 주파수가 주어진다 (주파수는 1000 보다 작다). www.acmicpc.net a, b = map(int, input().split()) n = int(input()) data = [] for _ in range(n) : data.append(int(input())) target = 1e9 for i in data : if abs(i - b) < abs(target - b) : target ..