Skip to content

Instantly share code, notes, and snippets.

@junodeveloper
Created January 17, 2018 16:36
Show Gist options
  • Save junodeveloper/52195a857a6879f536b33334a69e5a8b to your computer and use it in GitHub Desktop.
Save junodeveloper/52195a857a6879f536b33334a69e5a8b to your computer and use it in GitHub Desktop.
boj_10164
#include <cstdio>
#include <iostream>
using namespace std;
int n, m, k;
int c[31][31]; // Combination nCk
int main() {
for(int i=0; i<=30; i++) {
c[i][0] = 1;
for(int j=1; j<=i; j++)
c[i][j] = c[i-1][j] + c[i-1][j-1];
}
scanf("%d%d%d", &n, &m, &k);
int res;
if(!k) res = c[n+m-2][n-1];
else {
int x = (k-1) % m;
int y = (k-1) / m;
res = c[x+y][x] * c[n-y-1+m-x-1][n-y-1];
}
printf("%d", res);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment