¹æ¹ý 1. "¿¬¼ÓÇÑ n ÀÚ¸® ÀÚ¿¬¼ö´Â n ÀÇ ¹è¼öÀÌ´Ù." ¸¦ ÀÌ¿ëÇÕ´Ï´Ù.¹æ¹ý 2. Á¡È½Ä ÀÌ¿ënCr = n*(n-1)*...(n-r+1)/1*2*...*n
À̹ǷΠn*(n-1) Àº 2 , n*(n-1)*(n-2) ´Â 3 À» ¾à¼ö·Î °¡Áö¹Ç·Î ...
ans = 1; for( i = 1 , j = n ; i <= n ; i++,j--){ ans *= j/i; }¹®¼¿¡¼ µÎ ¹ø° Á¡È½Ä ÀÌ¿ë#include <stdio.h> unsigned long long f(int n,int r) { if ( r == 1) return n; return f(n-1,r-1)*n/r; } int main() { int n,r; scanf("%d %d",&n,&r); printf("%d things taken %d at a time is %llu exactly.\n",n,r,f(n,r)); }