Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

直接扫会超时,需要处理下k

Posted by zorulee at 2017-04-22 21:27:03 on Problem 2249
#include<cstdio>
typedef long long ll;
int main()
{
    int n,k;
    while(scanf("%d%d",&n,&k) && n+k){
        ll ans=1;
        if(k>n/2) k=n-k;
        for(int i=1;i<=k;++i)
            ans=ans*(n-i+1)/i;
        printf("%lld\n",ans);
    }
    return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator