baekjoon 20260108
This commit is contained in:
parent
fe7403f17c
commit
fafa00de92
28
code_study/Baekjoon/java/_10844.java
Normal file
28
code_study/Baekjoon/java/_10844.java
Normal file
@ -0,0 +1,28 @@
|
||||
import java.util.Scanner;
|
||||
|
||||
public class _10844 {
|
||||
public static void main(String[] args) {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
int N = sc.nextInt();
|
||||
sc.close();
|
||||
|
||||
long MOD = 1000000000;
|
||||
long[][] dp = new long[N+1][10];
|
||||
for(int i=1; i<10; i++) dp[1][i] = 1;
|
||||
|
||||
for(int i=2; i<=N; i++) {
|
||||
for(int j=0; j<10; j++) {
|
||||
if(j==0) dp[i][j] = dp[i-1][1]%MOD;
|
||||
else if(j==9) dp[i][j] = dp[i-1][8]%MOD;
|
||||
else dp[i][j] = dp[i-1][j-1]%MOD + dp[i-1][j+1]%MOD;
|
||||
}
|
||||
}
|
||||
|
||||
long res = 0;
|
||||
for (long n : dp[N]) {
|
||||
res += n;
|
||||
res %= MOD;
|
||||
}
|
||||
System.out.println(res);
|
||||
}
|
||||
}
|
||||
48
code_study/Baekjoon/java/_1562.java
Normal file
48
code_study/Baekjoon/java/_1562.java
Normal file
@ -0,0 +1,48 @@
|
||||
import java.util.*;
|
||||
|
||||
public class _1562 {
|
||||
public static void main(String[] args) {
|
||||
Scanner sc = new Scanner(System.in);
|
||||
int N = sc.nextInt();
|
||||
sc.close();
|
||||
|
||||
if(N <= 10) {
|
||||
System.out.println(N/10);
|
||||
return;
|
||||
}
|
||||
|
||||
long MOD = 1000000000;
|
||||
long[][][] dp = new long[N+1][10][1024];
|
||||
for(int i=1; i<10; i++) dp[1][i][1<<i] = 1;
|
||||
|
||||
|
||||
for(int length = 1; length < N; length++) {
|
||||
for(int last_num = 0; last_num < 10; last_num++) {
|
||||
for(int bit_state = 0; bit_state < 1024; bit_state++) {
|
||||
if(dp[length][last_num][bit_state] == 0) continue;
|
||||
|
||||
int next_num = last_num + 1;
|
||||
if(0<=next_num && next_num<=9) {
|
||||
int next_bit_state = bit_state | (1<<next_num);
|
||||
dp[length+1][next_num][next_bit_state] += dp[length][last_num][bit_state];
|
||||
dp[length+1][next_num][next_bit_state] %= MOD;
|
||||
}
|
||||
|
||||
next_num = last_num - 1;
|
||||
if(0<=next_num && next_num<=9) {
|
||||
int next_bit_state = bit_state | (1<<next_num);
|
||||
dp[length+1][next_num][next_bit_state] += dp[length][last_num][bit_state];
|
||||
dp[length+1][next_num][next_bit_state] %= MOD;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
long ans = 0;
|
||||
for(int i=0; i<10; i++) {
|
||||
ans += dp[N][i][1023];
|
||||
ans %= MOD;
|
||||
}
|
||||
System.out.println(ans);
|
||||
}
|
||||
}
|
||||
1
code_study/Baekjoon/python/34945.py
Normal file
1
code_study/Baekjoon/python/34945.py
Normal file
@ -0,0 +1 @@
|
||||
print("Success!" if int(input()) > 5 else "Oh My God!")
|
||||
Loading…
x
Reference in New Issue
Block a user