ZOJ 1938 Binomial & & poj 2249 (Binomial Showdown) (잠 자기 전 물)
제목:
In how many ways can you choose k elements out of n elements, not taking order into account? Write a program to compute this number.
정수 n 과 k 를 드 리 겠 습 니 다. 조합 수 c (n, k) 를 구 하 라 고 합 니 다.
코드:
#include <cstdio>
#include <cstring>
#include <math.h>
typedef long long LL;
LL ans,n,k;
int main()
{
while(scanf("%lld%lld",&n,&k),n)
{
ans=1;
if(k == 0)
{
printf("1
");
continue;
}
k=n-k>k?k:n-k;
//if(k>n-k)k=n-k;
for(int i=1; i<=k; i++)
{
ans=ans*(n-i+1)/i;
}
printf("%lld
",ans);
}
return 0;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
hdu 1233 절 대 컴퓨터 대학원 재시험모 성에 서 마을 의 교통 상황 을 조사 하여 얻 은 통계표 에는 임의의 두 마을 간 의 거리 가 열거 되 어 있다.성 정부의 '원활 한 공사' 목 표 는 성 전체의 어느 두 마을 간 에 도 도로 교통 을 실현 할 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.