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 veryhuman at 2009-04-01 13:47:02 on Problem 1496
In Reply To:Re:一些数据 Posted by:waitingRu at 2009-04-01 13:02:53
> 
> 数据都通过了 还是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;
> }

BS 一下数制转换.....

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