2(2)
-
백준 - 12101 - 1, 2, 3 더하기 2
https://www.acmicpc.net/problem/12101 12101번: 1, 2, 3 더하기 2 n을 1, 2, 3의 합으로 나타내는 방법 중에서 사전 순으로 k번째에 오는 것을 출력한다. k번째 오는 식이 없는 경우에는 -1을 출력한다. www.acmicpc.net import java.util.Scanner; /** * 12101 */ public class 일이삼더하기2 { private static int k; private static int count; private static String result = null; public static void main(String[] args) { Scanner sc = new Scanner(System.in); String[] input ..
2021.09.09 -
백준 - 9095 - 1, 2, 3 더하기
https://www.acmicpc.net/problem/9095 9095번: 1, 2, 3 더하기 각 테스트 케이스마다, n을 1, 2, 3의 합으로 나타내는 방법의 수를 출력한다. www.acmicpc.net 1. 백트래킹을 이용한 구현 import java.util.Scanner; /** * 9095 */ public class 일이삼더하기1 { private static int count; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = Integer.parseInt(sc.nextLine()); for (int i = 0; i < T; i++) { int targetNumber = Intege..
2021.09.09