Created
March 26, 2018 13:36
-
-
Save Tdrj2716/ffbf209a4e8c153873ea2b7e06322567 to your computer and use it in GitHub Desktop.
動的計画法の練習(Combination)
This file contains 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
#include <stdio.h> | |
#include <algorithm> | |
using namespace std; | |
int memo[30][30]; | |
int dp(int i, int j) | |
{ | |
if(memo[i][j] != -1) | |
return memo[i][j]; | |
else if(i == 0 || j == 0) | |
return memo[i][j] = 1; | |
else | |
return memo[i][j] = dp(i-1, j) + dp(i, j-1); | |
} | |
int main() | |
{ | |
int h, w; | |
scanf("%d %d", &h, &w); | |
fill(memo[0], memo[h], -1); | |
printf("%d", dp(h-1, w-1)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment