-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
JangHongJoon
committed
Mar 27, 2024
1 parent
18146fb
commit ccd1946
Showing
3 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import sys | ||
input = sys.stdin.readline | ||
|
||
def fib(n) : | ||
global countFib | ||
if n==1 or n==2: | ||
countFib += 1 | ||
return 1 | ||
else : | ||
return fib(n-1) + fib(n-2) | ||
|
||
def fibo(n): | ||
global countFibo | ||
f = [0 for _ in range(n+1)] | ||
f[1] = f[2] = 1 | ||
for idx in range(3, n+1): | ||
countFibo+=1 | ||
f[idx] = f[idx-1] + f[idx-2] | ||
return f[n] | ||
|
||
N = int(input()) | ||
countFib = countFibo = 0 | ||
fib(N) | ||
fibo(N) | ||
print(countFib, countFibo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import sys | ||
input = sys.stdin.readline | ||
|
||
def w(a,b,c): | ||
if a<=0 or b<=0 or c<=0 : | ||
return 1 | ||
if a>20 or b>20 or c>20: | ||
return w(20,20,20) | ||
if dp[a][b][c] : | ||
return dp[a][b][c] | ||
if a<b<c: | ||
dp[a][b][c] = w(a,b,c-1)+w(a,b-1,c-1)-w(a,b-1,c) | ||
return dp[a][b][c] | ||
dp[a][b][c] = w(a-1,b,c)+w(a-1,b-1,c)+w(a-1,b,c-1)-w(a-1,b-1,c-1) | ||
return dp[a][b][c] | ||
|
||
|
||
dp = [[[0] * 21 for _ in range(21)] for _ in range(21)] | ||
|
||
while True: | ||
a,b,c = map(int, input().split()) | ||
if a==b==c==-1 : break | ||
print(f'w({a}, {b}, {c}) = {w(a,b,c)}') | ||
|
||
|