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啊??谁能给点数据啊??

Posted by 42292624 at 2010-03-26 23:32:21 on Problem 1850
#include<stdio.h>
#include<string.h>
__int64 C(int n,int m)
{
    __int64 sum=1;
	if(n==0||m==0)
		return 1;
    if(m>n/2)
        m=n-m;
    for(int i=1;i<=m;i++)
    {
        sum*=(n-i+1);
        if(sum%i==0)
            sum/=i;
    }
    return sum;
}
char str[27];
int main()
{
    scanf("%s",str);
	__int64 sum=0;
    int l=strlen(str);
    int i,j;
	for(i=0;i<l-1;i++)
		if(str[i]>=str[i+1])
			break;
	if(i<l-1)
		printf("0\n");
	else
	{
	for(i=1;i<=l-1;i++)
		sum+=C(26,i);
    for(i=l-1;i>0;i--)
    {
        int n=str[i]-str[i-1]-1;
        for(j=str[i-1]+1;j<str[i];j++)
            sum+=C(26-(j-str[i-1]),l-i-1);
    }
    for(i=1;i<=str[0]-'a';i++)
        sum+=C(26-i,l-1);
    printf("%I64d\n",sum+1);
	}
    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