diff --git "a/9\354\233\224 28\354\235\274 - \353\217\231\354\240\201 \352\263\204\355\232\215\353\262\225/10844.cpp" "b/9\354\233\224 28\354\235\274 - \353\217\231\354\240\201 \352\263\204\355\232\215\353\262\225/10844.cpp" new file mode 100644 index 0000000..129a64f --- /dev/null +++ "b/9\354\233\224 28\354\235\274 - \353\217\231\354\240\201 \352\263\204\355\232\215\353\262\225/10844.cpp" @@ -0,0 +1,44 @@ +#include +#include + +using namespace std; + +#define DIV 1000000000; + +int main() +{ + int n, ans = 0; + cin >> n; + vector> dp(100, vector(10,0)); + // 한 자리 수 + for (int i = 0; i < 10; i++) + dp[0][i] = 1; + // i: 자리의 수, j: 일의 자리 수 + for (int i = 1; i < n; i++) + { + for (int j = 0; j < 10; j++) + { + if (j == 0) // 일의 자리 수가 0 + dp[i][0] = dp[i - 1][1]; + else if (j == 9) // 일의 자리 수가 9 + dp[i][9] = dp[i - 1][8]; + else // 일의 자리 수가 1~8 + dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j + 1]; + dp[i][j] = dp[i][j] % DIV; + } + } + /* + for (int a = 0; a < n; a++) + { + for (int b = 0; b < 10; b++) + cout << dp[a][b] << ' '; + cout << '\n'; + } + cout << '\n'; + */ + // 0으로 시작하는 것 제외 + for (int i = 1; i < 10; i++) + ans = (ans + dp[n-1][i]) % DIV; + cout << ans <<'\n'; + return 0; +} \ No newline at end of file diff --git "a/9\354\233\224 28\354\235\274 - \353\217\231\354\240\201 \352\263\204\355\232\215\353\262\225/15486.cpp" "b/9\354\233\224 28\354\235\274 - \353\217\231\354\240\201 \352\263\204\355\232\215\353\262\225/15486.cpp" new file mode 100644 index 0000000..71d90d5 --- /dev/null +++ "b/9\354\233\224 28\354\235\274 - \353\217\231\354\240\201 \352\263\204\355\232\215\353\262\225/15486.cpp" @@ -0,0 +1,26 @@ +#include +#include +#include + +using namespace std; + +// 14501 보다 N의 범위가 크다 (1500000) +int main() +{ + int n; + cin >> n; + vector> v; + v.assign(n, {}); + // 입력 + for (int i = 0; i < n; i++) + cin >> v[i].first >> v[i].second; + vector dp(1500001, 0); + for(int i=0; i +#include + +using namespace std; + +deque d[2], g[2]; +int turn = 0; + +void round() +{ + // SUYEON + if (!g[0].empty() && !g[1].empty() && (g[0].front() + g[1].front() == 5)) + { + while (!g[0].empty()) + { + d[1].push_back(g[0].back()); + g[0].pop_back(); + } + while (!g[1].empty()) + { + d[1].push_back(g[1].back()); + g[1].pop_back(); + } + } + // DODO + else if ((!g[0].empty() && g[0].front() == 5) || (!g[1].empty() && g[1].front() == 5)) + { + while (!g[1].empty()) + { + d[0].push_back(g[1].back()); + g[1].pop_back(); + } + while (!g[0].empty()) + { + d[0].push_back(g[0].back()); + g[0].pop_back(); + } + } +} + +string win() +{ + if (d[0].size() > d[1].size()) + return "do"; + else if (d[0].size() < d[1].size()) + return "su"; + return "dosu"; +} + +string game(int m) +{ + while (m--) + { + g[turn].push_front(d[turn].front()); + d[turn].pop_front(); + if (d[turn].empty()) + break; + round(); + turn = (turn == 1) ? 0 : 1; + } + return win(); +} + +int main() +{ + int n, m, input1, input2; + cin >> n >> m; + for (int i = 0; i < n; i++) + { + cin >> input1 >> input2; + d[0].push_front(input1); + d[1].push_front(input2); + } + cout << game(m)<<'\n'; +} \ No newline at end of file diff --git "a/9\354\233\224 28\354\235\274 - \353\217\231\354\240\201 \352\263\204\355\232\215\353\262\225/2294.cpp" "b/9\354\233\224 28\354\235\274 - \353\217\231\354\240\201 \352\263\204\355\232\215\353\262\225/2294.cpp" new file mode 100644 index 0000000..ba37189 --- /dev/null +++ "b/9\354\233\224 28\354\235\274 - \353\217\231\354\240\201 \352\263\204\355\232\215\353\262\225/2294.cpp" @@ -0,0 +1,29 @@ +#include +#include +#include + +using namespace std; + +int main() +{ + int n, k, input; + cin >> n >> k; + vector coin(100, 0); + // 동전의 최대 가치 100000만큼 dp 생성 + // 최솟값을 구해야 하므로 10001(k의 최대값보다 큰 값)로 초기화 + vector dp(100001, 10001); + dp[0] = 0; + // 코인 값 입력 + for (int i = 0; i < n; i++) + cin >> coin[i]; + // 최솟값 구하기 + for (int i = 0; i < n; i++) + for (int j = coin[i]; j <= k; j++) + dp[j] = min(dp[j], dp[j - coin [i]] + 1); + // 불가능한 경우 -1 출력 + if (dp[k] == 10001) + cout << -1 << '\n'; + else + cout << dp[k] << '\n'; + return 0; +} \ No newline at end of file diff --git "a/9\354\233\224 28\354\235\274 - \353\217\231\354\240\201 \352\263\204\355\232\215\353\262\225/3190.cpp" "b/9\354\233\224 28\354\235\274 - \353\217\231\354\240\201 \352\263\204\355\232\215\353\262\225/3190.cpp" new file mode 100644 index 0000000..e3a42d4 --- /dev/null +++ "b/9\354\233\224 28\354\235\274 - \353\217\231\354\240\201 \352\263\204\355\232\215\353\262\225/3190.cpp" @@ -0,0 +1,89 @@ +#include +#include + +using namespace std; + +int n, l; +vector> d(l, { 0, ' ' }); +// 오른쪽: 0 아래: 1 왼쪽: 2 위: 3 +vector> move_dir = { { 0, 1 }, { 1, 0 }, { 0, -1 }, { -1, 0 } }; + +bool inRange(int a, int b) +{ + if (a < 0 || a >= n || b < 0 || b >= n) + return false; + return true; +} + +int dummy(vector> board) +{ + int cnt = 0, d_cnt = 0, curr_dir = 0, apple = 0; + char turn_d = ' '; + int tail_length = 1, head_length = 1, r_tail = 0, c_tail = 0, r_head = 0, c_head = 0; + board[0][0] = 1; + while (true) + { + // 시간 증가 + cnt++; + // 뱀 머리 이동 + if (!inRange(r_head + move_dir[curr_dir].first, c_head + move_dir[curr_dir].second) || board[r_head + move_dir[curr_dir].first][c_head + move_dir[curr_dir].second] > 0) + return cnt; + else + { + r_head += move_dir[curr_dir].first; + c_head += move_dir[curr_dir].second; + apple = board[r_head][c_head] == -1 ? 1 : 0; + board[r_head][c_head] = ++head_length; + } + if (apple == 0) // 사과를 못 먹은 경우 몸 길이 유지 + { + board[r_tail][c_tail] = 0; + tail_length++; + for (int i = 0; i < 4; i++) + { + if (inRange(r_tail + move_dir[i].first, c_tail + move_dir[i].second) && board[r_tail + move_dir[i].first][c_tail + move_dir[i].second] == tail_length) + { + r_tail += move_dir[i].first; + c_tail += move_dir[i].second; + break; + } + } + } + // 뱀의 방향 변환 정보 + if (d_cnt < l) + { + if (d[d_cnt].first == cnt) + { + turn_d = d[d_cnt].second; + d_cnt++; + if (turn_d == 'L') + curr_dir = curr_dir == 0 ? 3 : curr_dir - 1; + else if (turn_d == 'D') + curr_dir = curr_dir == 3 ? 0 : curr_dir + 1; + } + } + } +} + +int main() +{ + int k; + cin >> n >> k; + vector> board(n, vector(n, 0)); + int row, col, x; + char c; + // 사과 + for (int i = 0; i < k; i++) + { + cin >> row >> col; + board[row-1][col-1] = -1; + } + // 방향 + cin >> l; + for (int i = 0; i < l; i++) + { + cin >> x >> c; + d.push_back(make_pair(x, c)); + } + cout << dummy(board) << '\n'; +} \ No newline at end of file