Skip to content

Commit

Permalink
22.08.12
Browse files Browse the repository at this point in the history
  • Loading branch information
delena0702 authored Aug 12, 2022
1 parent a16a35b commit 2b4e738
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
24 changes: 24 additions & 0 deletions BAEKJOON/2413_비슷한_순열.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import sys
def input(): return sys.stdin.readline().strip()

N = int(input())
data = list(map(int, input().split()))

order = [0] * (N + 1)
for i in range(N):
order[data[i]] = i

check = [False] * (N + 1)
check[0] = True

for i in range(N):
if check[data[i]] or check[data[i] - 1]:
continue

if order[data[i] - 1] < i:
continue

check[data[i]] = check[data[i] - 1] = True
data[order[data[i] - 1]] = data[i]
data[i] = data[i] - 1
print(*data, sep=' ')
25 changes: 25 additions & 0 deletions BAEKJOON/3908_서로_다른_소수의_합.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import sys
def input(): return sys.stdin.readline().strip()

SIZE_N, SIZE_K = 1120, 14

is_prime = [True] * (SIZE_N + 1)
primes = []
for i in range(2, SIZE_N + 1):
if not is_prime[i]:
continue
for j in range(2 * i, SIZE_N + 1, i):
is_prime[j] = False
primes.append(i)

dp = [[0] * (SIZE_K + 1) for _ in range(SIZE_N + 1)]
dp[0][0] = 1
for prime in primes:
for i in range(SIZE_N, prime - 1, -1):
for j in range(1, SIZE_K + 1):
dp[i][j] = dp[i][j] + dp[i - prime][j - 1]

T = int(input())
for _ in range(T):
n, k = map(int, input().split())
print(dp[n][k])

0 comments on commit 2b4e738

Please sign in to comment.