baekjoon 20260125

This commit is contained in:
songyc macbook 2026-01-25 19:40:17 +09:00
parent b6350b53e0
commit 32dd42ca61
3 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,11 @@
import java.util.*;
public class _11943 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt(), D = sc.nextInt();
sc.close();
System.out.println(Math.min(A+D, B+C));
}
}

View File

@ -0,0 +1,25 @@
let N: Int = Int(readLine()!)!
let MOD: Int = 1000000000
var dp: [Int] = Array(repeating: 1, count: 10)
dp[0] = 0
for _ in 1..<N {
var next_dp: [Int] = Array(repeating: 0, count: 10)
for i in 0...9 {
if i == 0 {
next_dp[i] = dp[1]
}
else if i==9 {
next_dp[i] = dp[8]
}
else {
next_dp[i] = (dp[i-1] + dp[i+1])%MOD
}
}
dp = next_dp
}
print(dp.reduce(0,+)%MOD)

View File

@ -0,0 +1,44 @@
import Foundation
let N: Int = Int(readLine()!)!
let MOD: Int = 1000000000
if N < 10 {
print(0)
exit(0)
}
var dp: [[[Int]]] = Array(repeating: Array(repeating: Array(repeating: 0, count: 1024), count: 10), count: N+1)
for n in 1...9 {
dp[1][n][1<<n] = 1
}
for length in 1..<N {
for num in 0...9 {
for bit_state in 0..<1024 {
if dp[length][num][bit_state] == 0 {
continue
}
var next = num - 1
if next >= 0 {
let next_bit_state = bit_state | (1<<next)
dp[length+1][next][next_bit_state] += dp[length][num][bit_state]
dp[length+1][next][next_bit_state] %= MOD
}
next = num + 1
if next < 10 {
let next_bit_state = bit_state | (1<<next)
dp[length+1][next][next_bit_state] += dp[length][num][bit_state]
dp[length+1][next][next_bit_state] %= MOD
}
}
}
}
var ans = 0
for n in 0...9 {
ans = (ans + dp[N][n][1023])%MOD
}
print(ans)