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

WA 无数遍 终于写出的0ms 直接从前向后扫描能过 从后向前据WA了

Posted by 893203990 at 2013-07-09 17:39:41 on Problem 2249
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
#define mmax 10000000
typedef __int64 ll;
ll ans(ll x,ll y)
{
    if(y==0)
        return 1;
    ll  i,j;
    ll ans=1;
    j=1;
    for(i=x-y+1;i<=x;i++)
    {
        ans=ans*i;
       // printf("%I64d ",i);
        while(ans%j==0&&j<=y)
        {
            ans/=j;
            j++;
        }

    }
    return ans;
}
int main()
{
    ll n,k;
    while(scanf("%I64d %I64d",&n,&k)!=EOF&&(n!=0||k!=0))
    {
        if(2*k>n)
            printf("%I64d\n",ans(n,n-k));
        else
            printf("%I64d\n",ans(n,k));
    }
    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