Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
大水題#include <iostream> #include <stdio.h> #include <cstring> using namespace std; char word[8]; int len; int ljgs[6] = {0,26,351,2951,17901,83681}; int cc(int a, int b){ int C = 1; for(int A = a; A > a-b; A--) C *= A; for(int B = b; B > 0; B--) C /= B; return C; } bool isAsc(){ len = strlen(word); for(int i = 1; i < len; i++){ if(word[i-1] >= word[i]) return 0; } return 1; } int getOrder(){ if(!isAsc()) return 0; int ans = 1 + ljgs[len-1]; for(int i = 0; i < len; i++){ char start; if(i == 0) start = 'a'; else start = word[i-1] + 1; for(char c = start; c < word[i]; c++){ ans += cc(25-(c-'a'), len-i-1); } } return ans; } int main() { while(scanf("%s", word) > 0){ printf("%d\n", getOrder()); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator