poj1496(组合数学)-与1850几乎一样
来源:互联网 发布:柴犬为什么会笑 知乎 编辑:程序博客网 时间:2024/05/17 22:25
http://poj.org/problem?id=1496
Word Index
Time Limit: 1000MSMemory Limit: 10000KTotal Submissions: 3969Accepted: 2247
Description
Encoding schemes areoften used in situations requiring encryption or informationstorage/transmission economy. Here, we develop a simple encodingscheme that encodes particular types of words with five or fewer(lower case) letters as integers.
Consider the English alphabet {a,b,c,...,z}. Using this alphabet, aset of valid words are to be formed that are in a strictlexicographic order. In this set of valid words, the successiveletters of a word are in a strictly ascending order; that is, laterletters in a valid word are always after previous letters withrespect to their positions in the alphabet list {a,b,c,...,z}. Forexample,
abc aep gwz
are all valid three-letter words, whereas
aab are cat
are not.
For each valid word associate an integer which gives the positionof the word in the alphabetized list of words. That is:
Your program is to read a series of input lines. Each input linewill have a single word on it, that will be from one to fiveletters long. For each word read, if the word is invalid give thenumber 0. If the word read is valid, give the word's position indexin the above alphabetical list.
Consider the English alphabet {a,b,c,...,z}. Using this alphabet, aset of valid words are to be formed that are in a strictlexicographic order. In this set of valid words, the successiveletters of a word are in a strictly ascending order; that is, laterletters in a valid word are always after previous letters withrespect to their positions in the alphabet list {a,b,c,...,z}. Forexample,
abc aep gwz
are all valid three-letter words, whereas
aab are cat
are not.
For each valid word associate an integer which gives the positionof the word in the alphabetized list of words. That is:
a -> 1
b -> 2
.
.
z -> 26
ab -> 27
ac -> 28
.
.
az -> 51
bc -> 52
.
.
vwxyz -> 83681
Your program is to read a series of input lines. Each input linewill have a single word on it, that will be from one to fiveletters long. For each word read, if the word is invalid give thenumber 0. If the word read is valid, give the word's position indexin the above alphabetical list.
Input
The input consistsof a series of single words, one per line. The words are at leastone letter long and no more that five letters. Only the lower casealphabetic {a,b,...,z} characters will be used as input. The firstletter of a word will appear as the first character on an inputline.
The input will be terminated by end-of-file.
The input will be terminated by end-of-file.
Output
The output is asingle integer, greater than or equal to zero (0) and less than orequal 83681. The first digit of an output value should be the firstcharacter on a line. There is one line of output for each inputline.
Sample Input
zacatvwxyz
Sample Output
261083681
Source
East Central North America 1995
详解参照上一篇文章poj1850。。
#include
#include
#include
using namespace std;
int c[27][27]={0};
void Init()
{
for(inti=0;i<=26;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;
return;
}
int main()
{
charstr[12];
while(scanf("%s",str)!=EOF)
{
bool flag=false;
Init();
int len=strlen(str);
for(int i=0;i<=len-2;i++)
{
if(str[i]>=str[i+1])
{
printf("0\n");
flag=true;
//return 0;
}
}
int sum=0;
if(flag==false)
{
#include
#include
using namespace std;
int c[27][27]={0};
void Init()
{
}
int main()
{
}
- poj1496(组合数学)-与1850几乎一样
- poj1850/poj1496 组合数
- poj1496
- poj1496—Word Index(组合数)
- 《组合数学》第二章-排列与组合
- poj 1850组合数学
- poj 1850(组合数学)
- 二聚物问题与组合数学
- Firefox、Chrome跑JavaScript几乎一样快
- GlueGen...几乎和JOGL一样酷?
- Code POJ 1850 组合数学
- POJ 1850/ 1496 组合数学
- poj 1850 Code 组合数学
- poj 1850 Code (组合数学)
- POJ 1850-Code(组合数学)
- POJ 1850:Code 组合数学
- POJ 1850 Code(组合数学)
- POJ-1850-Code-组合数学
- hdu1969(二分法)
- cfdiv2_140
- 知识点(求n!的末尾有几个零)
- poj1401(计算n!中0的个数)
- poj1850(组合数学)
- poj1496(组合数学)-与1850几乎一样
- cf141div2
- 组合数学知识点
- poj2409(polya计数 套模版)
- poj1286(polya计数 套模版)
- 快捷方式引起的home键问题
- 数据结构_栈实现数值转换
- 教大家快捷的生成和解析xml
- poj2249(排列组合__套模板)