This repository was archived by the owner on Feb 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
[감자] 2021年06月22日 #110
Closed
Closed
[감자] 2021年06月22日 #110
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
dkswndms4782/dynamic_programming_1/1010_다리놓기.cpp
This file contains hidden or 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,36 @@ | ||
| #include <iostream> | ||
| #include <cmath> | ||
| using namespace std; | ||
|
|
||
| unsigned long long factorial[31] = { 1, }; | ||
| void make_factoral() { | ||
| factorial[1] = 1; | ||
| for (int i = 2; i <= 15; i++) { | ||
| factorial[i] = factorial[i - 1] * i; | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| unsigned long long num(int m,int n) { | ||
| unsigned long long tmp = m; | ||
| for (int i = m - 1; i > m - n; i--) | ||
| tmp *= i; | ||
| return tmp; | ||
| } | ||
|
|
||
| int main() { | ||
| ios_base::sync_with_stdio(false); | ||
| cin.tie(NULL); | ||
| int T, n, m; cin >> T; | ||
| make_factoral(); | ||
| while (T--) { | ||
| cin >> n >> m; | ||
| if (n == m) { | ||
| cout << "1\n"; | ||
| continue; | ||
| } | ||
| if (n > (m-n)) | ||
| n = m - n; | ||
| cout << num(m,n) / factorial[n] << "\n"; | ||
| } | ||
| } |
19 changes: 19 additions & 0 deletions
dkswndms4782/dynamic_programming_1/2748_피보나치수2.cpp
This file contains hidden or 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,19 @@ | ||
| #include <iostream> | ||
| using namespace std; | ||
|
|
||
| long long int arr[91] = {0,}; | ||
| long long int dp(int n) { | ||
| if (n < 2) | ||
| return n; | ||
| if (arr[n] > 0) | ||
| return arr[n]; | ||
| arr[n] = dp(n - 1) + dp(n - 2); | ||
| return arr[n]; | ||
| } | ||
|
|
||
| int main() { | ||
| ios_base::sync_with_stdio(false); | ||
| cin.tie(NULL); | ||
| int n; cin >> n; | ||
| cout << dp(n); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.