poj 1850 Code 1496 Word Index
2012-08-06 16:50
344 查看
这个题是组合题:
View Code
View Code
#include<iostream> #include<cstdio> #include<cstdlib> #include<algorithm> #include<cmath> #include<queue> #include<set> #include<map> #include<cstring> #include<vector> #include<string> #define LL long long using namespace std; void Init( int c[][27] ) { for( int i = 0 ; i < 27; i ++ ) for( int j = 0 ; j <= i ; j ++ ) { if( j == 0 || i == j ) c[i][j] = 1; else c[i][j] = c[i-1][j-1] + c[i-1][j]; } c[0][0] = 0; } int main( ) { int c[27][27]; char str[12]; Init( c ); while( scanf( "%s",str )==1 ) { int len = strlen( str ),flag = 0; for( int i = 1; i < len ; i ++ ) { if( str[i] < str[i-1] ) { flag = 1; puts( "0" ); return 0; } } int sum = 0; for( int i = 1 ; i < len ; i ++ ) sum += c[26][i]; for( int i = 0 ; i < len ; i++ ) { char s = i==0?'a':str[i-1] + 1; while( s < str[i] ) { sum += c['z'-s][len-i-1]; s++; } } printf( "%d\n",++sum ); } //system( "pause" ); return 0; }
相关文章推荐
- poj 1850 Code(同 poj 1496 Word Index)
- 排列组合:poj 1496 Word Index+poj 1850 Code
- Poj 1496 Word Index & Poj 1850 Code (计数 组合数)
- POJ 1850 Code/POJ 1496 Word Index(组合数学-字母串序号)
- POJ 1850 Code ,1496 Word Index(组合计数)
- POJ 1496 Word Index || POJ 1850 Code
- POJ-1850-Code-组合数学
- POJ 1850/ 1496 组合数学
- 【poj 1850】Code 题意&题解&代码(C++)
- POJ 1850 Code (递推数学)
- POJ 1850 Code (组合数学)
- Code(POJ--1850
- POJ1850——Code(组合数学)
- poj 1850 Code
- poj 1496(1850)/2245 全组合打表(一种字符编码/Lotto)
- [poj 1850] Code 组合数学
- poj1496(组合数学)-与1850几乎一样
- poj 1850 Code
- [POJ 1850] Code
- poj 1850 Code