diff --git a/Solving/Team2/week1/seungkyun/14888.cpp b/Solving/Team2/week1/seungkyun/14888.cpp new file mode 100644 index 0000000..97760db --- /dev/null +++ b/Solving/Team2/week1/seungkyun/14888.cpp @@ -0,0 +1,38 @@ +#include +using namespace std; +int N, m = 1000000001, M = -1000000001; +int a[11]; +int d[4]; +void rr(int k, int cal) { + if (k == N) { + if (cal > M) + M = cal; + if (cal < m) + m = cal; + return; + } + for (int i = 0; i < 4; i++) { + if (d[i] > 0) { + d[i]--; + if (i == 0) + rr(k + 1, cal + a[k]); + if (i == 1) + rr(k + 1, cal - a[k]); + if (i == 2) + rr(k + 1, cal * a[k]); + if (i == 3) + rr(k + 1, cal / a[k]); + d[i]++; + } + } +} +int main() { + cin >> N; + for (int i = 0; i < N; i++) + cin >> a[i]; + for (int i = 0; i < 4; i++) + cin >> d[i]; + int cal = a[0]; + rr(1, cal); + cout << M << "\n" << m; +} diff --git a/Solving/Team2/week1/seungkyun/9663.cpp b/Solving/Team2/week1/seungkyun/9663.cpp new file mode 100644 index 0000000..2671bf6 --- /dev/null +++ b/Solving/Team2/week1/seungkyun/9663.cpp @@ -0,0 +1,51 @@ +#include +#include +using namespace std; +long long cnt = 0, N; +vector c, r; +void repeat(int k) { + c.push_back(k); + bool ok = true; + for (int i = 1; i <= N; i++) { + for (int j = 0; j < r.size(); j++) { + if (r.at(j) == i) { + ok = false; + break; + } + if (k - j - 1 == i - r.at(j)) { + ok = false; + break; + } + if (k - j - 1 == r.at(j) - i) { + ok = false; + break; + } + } + if (ok) { + r.push_back(i); + if (r.size() == N) { + cnt++; + r.pop_back(); + } + else { + repeat(k + 1); + r.pop_back(); + } + } + ok = true; + } + c.pop_back(); +} +int main() { + cin >> N; + c.push_back(1); + for (int i = 1; i <= N; i++) { + r.push_back(i); + repeat(2); + r.pop_back(); + } + if (N == 1) + cout << 1; + else + cout << cnt; +}