목록문제/백준_자바 (102)
sm 기술 블로그
import java.util.*; import java.io.*; class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[] arr = new int[n]; int[] arrDp = new int[n]; String[] tmp = br.readLine().split(" "); for (int i = 0; i < n; i++) { arr[i] = Integer.parseInt(tmp[i]); arrDp[i] = 1; } ..
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] wine = new int[n]; int[] wineDp = new int[n]; for (int i = 0; i < n; i++) { wine[i] = sc.nextInt(); } try { wineDp[0] = wine[0]; wineDp[1] = Math.max(wine[0] + wine[1], wine[1]); wineDp[2] = Math.max(Math.max(wine[0] + wine[1], wine[0] + wine[2]), wine..
import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); Long[][] dp = new Long[N + 1][10]; Long sum = 0L; for (int i = 0; i < N + 1; i++) { for (int j = 0; j < 10; j++) { dp[i][j] = 0L; } } for (int i = 1; i < 10; i++) { dp[0][i] = 1L; } for (int i = 1; i < N + 1; i++) { for (int j = 0; j < 10; j++) { if (j == 0) { dp[i..
N = int(input()) dp = [[0 for _ in range(10)] for _ in range(101)] for i in range(1,10): dp[1][i] = 1 for i in range(2,N+1): for j in range(10): if j == 0 : dp[i][j] = dp[i-1][1] elif j == 9: dp[i][j] = dp[i-1][8] else : dp[i][j] = dp[i-1][j-1] + dp[i-1][j+1] print(sum(dp[N]) % 1000000000) 문제요약 서로 1씩 차이가 나는 수를 계단수라고 함. 길이 N이 주어졌을 때 계단수의 개수에 1000000000 을 나눈 나머지는 몇인가? (ex 길이 1 => 1 2 3 4 5 6 7 8 9..