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:一些数据

Posted by waitingRu at 2009-04-01 13:02:53 on Problem 1496
In Reply To:一些数据 Posted by:SmilingWang at 2009-03-06 13:29:25
> adx
> kmp
> cgp
> bpz
> efs
> eln
> kuy
> fns
> fkq
> imo
> ceu
> ajx
> dkq
> dho
> hsz
> cer
> gio
> hmy
> fit
> eiw
> qtx
> ehv
> gsv
> gvz
> nux
> alz
> jrv
> cir
> 
> 418
> 2408
> 999
> 882
> 1424
> 1518
> 2485
> 1738
> 1697
> 2182
> 965
> 529
> 1297
> 1247
> 2114
> 962
> 1835
> 2056
> 1669
> 1482
> 2850
> 1464
> 1957
> 1976
> 2719
> 560
> 2359
> 1036

数据都通过了 还是WA......
#include <iostream>
#include <cstring>

using namespace std;

__int64 Com ( unsigned n, unsigned m )
{
	m = m > n / 2 ? n - m : m;
	double result = 1.0;
	for ( int i = m; i >= 1; --i, --n )
		result *= n * 1.0 / i;
	return (__int64)result;
}

__int64 Cal ( char c, int len )
{
	return Com ( 'z'-c, len );
}

bool check ( string s )
{
	for ( int i = 1; i != s.size(); ++i )
		if ( s[i] - s[i-1] <= 0 ) return 0;
	return 1;
}

int main()
{
	string s;
	int len, pos;
	__int64 result;
	while ( cin >> s ){
		if ( !check(s) ){
			cout << 0 << endl;
			continue;
		}
		result = 0;
		len = s.size();
		for ( int i = 1; i != len; ++i )
			result += Com(26,i);
		for ( pos = 0; pos != len; ++pos )
			for ( char i = !pos ? 'a'+pos : s[pos-1] + 1; i != s[pos]; ++i )
				result += Cal(i,len-pos-1);
		cout << ++result << endl;
	}
	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