-
[12180] Googlander (Small)BOJ 2021. 10. 7. 01:37
https://www.acmicpc.net/problem/12180
12180번: Googlander (Small)
In Case #1, Googlander cannot make any moves. The only possible path is the trivial one consisting of the only square. In Case #2, Googlander cannot take a step straight ahead, because it would take him off the stage, but he can turn right and then take a
www.acmicpc.net
<문제>
R과 C가 작아 시뮬레이션으로도 해결이 가능할것으로 보인다.
dp로 해결할때에 필요한 점화식은 dp[i][j] = dp[i-1][j]+dp[i][j-1]
위 점화식을 이용해 2차원 dp를 아래처럼 구성할 수 있다.
dp[i][j] : i행 j열의 맵의 경우의 수
<소스코드>
12345678910111213141516171819#include <bits/stdc++.h>using namespace std;int t, dp[11][11];int main(void) {int i, j;cin >> t;for (i = 1; i <= 10; i++) dp[i][1] = dp[1][i] = 1;for (i = 2; i <= 10; i++) {for (j = 2; j <= 10; j++) {dp[i][j] = dp[i - 1][j] + dp[i][j - 1];}}for (int T = 1; T <= t; T++) {int y, x;cin >> y >> x;cout << "Case #" << T << ": " << dp[y][x] << '\n';}return 0;}cs 'BOJ' 카테고리의 다른 글
[13549] 숨바꼭질 3 (0) 2021.10.08 [1005] ACM Craft (0) 2021.10.07 [9625] BABBA (0) 2021.10.07 [11726] 2×n 타일링 (0) 2021.10.05 [11653] 소인수분해 (0) 2021.10.05