Skip to content
This repository was archived by the owner on Feb 22, 2022. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions dkswndms4782/dynamic_programming_1/1010_다리놓기.cpp
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
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);
}