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:终于AC了,给大家参考参考!!!

Posted by 10190123 at 2011-07-26 10:48:49 on Problem 1850
In Reply To:终于AC了,给大家参考参考!!! Posted by:810974380 at 2009-07-27 15:48:44
> 
> 
> 
> #include<stdio.h>
> #include<string.h>
> int com(int n, int r)
> {// return C(n, r)
>     int i, j, s = 1;
> 	if(n-r>r) r=n-r; // C(n, r) = C(n, n-r)
>      for(i=0,j=1;i<r;++i)
> 	{
>        s *= (n-i);
>     for( ; j <= r && s%j == 0; ++j ) s /= j;
> 	}
>   return s;
> }
> int main()
> {
>    char str[15];int i,j,k,l,length,res;
>      scanf("%s",str);
>      length=strlen(str);
>      for( i=0;i<length; ++i )
>        for(k=i+1;k<length;k++)
> 		   if(str[i]>=str[k]) {putchar('0');return 0;}
> 		      res = 0;
>      for( j=1; j <= i; ++j ) res += com(26, j);
>      for( l=0; str[l]; ++l ) res -= com(26-(str[l]-'a'+1), i-l);
>      printf("%d",res);
> 	 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