Professional Documents
Culture Documents
Codechef Easy qn2
Codechef Easy qn2
C Programming
Code-Chef Submission
QUESTION: 2: FTRIP
EASY
Alice's school is planning to take some students from her class on a
field trip. Alice is really excited about it. There are a total of S
students in her class. But due to budget constraints, the school is
planning to take only N students for the trip. These students will be
picked randomly. And each student has equal chance of being
picked.
int main()
{int T,S,N,M,K,t,i;
double tmp,fav,tot;
scanf("%d",&T);
for(t=1;t<=T;t++)
{scanf("%d%d%d%d",&S,&N,&M,&K);
S--;
N--;
M--;
tmp=1,fav=0,tot=1;
i=MAX(N-S+M,0);
if(i>=K)fav = 1;
for(;i<M && i<N;i++){
tmp *= (double)(M-i)*(N-i)/((S-M-N+i+1)*(i+1));
APPROACH: