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

Re:1496过了,同样的代码,这题wa了

Posted by jkfbaidu at 2010-03-20 12:09:48 on Problem 1850
In Reply To:Re:1496过了,同样的代码,这题wa了 Posted by:jkfbaidu at 2010-03-20 12:09:16
> 改成单输入单输出还是wa,无语了
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char c[12];
int comb(int m,int n)
{
    int i,j;
    int a=1,b=1;
    for(i=m,j=n; j>=1; j--,i--)
    {
        a=a*i;
        b=b*j;
    }
    return a/b;
}

int main()
{
    int m;
    int sum;
    int i,j;
    int flag;

    scanf("%s",c);
    flag=0;
    m=strlen(c);
    for(i=0; i<m-1; i++)
        if(c[i]>=c[i+1])
        {
            flag=1;
        }
    sum=0;
    /*printf("*%d\n",comb(7,4));*/
    for(i=1; i<=m-1; i++)
        sum=sum+comb(26,i);

    sum=sum+comb(26,m);
    for(i=0; i<m; i++)
        sum=sum-comb(26-(c[i]-'a'+1),m-i);
    if(flag==0)
        printf("%d\n",sum);
    else
        printf("0\n");

    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