Created
August 6, 2015 07:14
-
-
Save luckypapa/310a17fde2c433fabeeb to your computer and use it in GitHub Desktop.
Bridge Link solution
This file contains hidden or 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
//https://www.acmicpc.net/problem/1010 | |
//time complexity : O(N) | |
//space complexity : O(1) | |
#include <stdio.h> | |
int combination(int west, int east) { | |
if (west >= 30 || east >= 30 || west > east) | |
return -1; | |
if (west == 0) return 0; | |
int ret = 1; | |
for(int i = 1; i <= west; i++) | |
ret = ret * (east - i + 1) / i; | |
return ret; | |
} | |
int main() { | |
int T; | |
scanf("%d", &T); | |
while(T-- > 0) { | |
int N, M; | |
scanf("%d %d", &N, &M); | |
printf("%d\n", combination(N, M)); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment