POJ 3073
来源:互联网 发布:电影剧本创作软件 编辑:程序博客网 时间:2024/06/01 08:55
Description
To thwart content-based spam filters, spammers often modify the text of a spam email to prevent its recognition by automatic filtering programs. For any plain text string s (containing only upper-case letters), let Φ(s) denote the string obtained by substituting each letter with its “spam alphabet” equivalent:
A
4
(four) N
|/|
(pipe backslash pipe) B
|3
(pipe three) O
0
(zero) C
(
(left-parenthesis) P
|0
(pipe zero) D
|)
(pipe right-parenthesis) Q
(,)
(left-parenthesis comma right-parenthesis) E
3
(three) R
|?
(pipe question-mark) F
|=
(pipe equals) S
5
(five) G
6
(six) T
7
(seven) H
#
(pound) U
|_|
(pipe underscore pipe) I
|
(pipe) V
//
(backslash forward-slash) J
_|
(underscore pipe) W
////
(backslash forward-slash backslash forward-slash) K
|<
(pipe less-than) X
><
(greater-than less-than) L
|_
(pipe underscore) Y
-/
(minus forward-slash) M
|//|
(pipe backslash forward-slash pipe) Z
2
(two) In this scheme, any plain text message s corresponds to exactly one spam-encoded message Φ(s). The reverse, however, is not necessarily true: a spam-encoded message may correspond to more than one plain text message.
Given a plain text message s, your goal is to determine the number of unique plain text messages whose spam encoding is Φ(s).
Input
The input test file will contain multiple test cases. Each test case consists of a single line containing a plain text string s containing from 1 to 100 upper-case letters. The end-of-file is denoted by a single line containing the word “end”.
Output
For each test case, print the number of unique plain text messages (including the original message) whose spam encoding is Φ(s). The number of unique plain text messages is guaranteed to be no greater than 1,000,000,000.
Sample Input
BUUJTHEQUICKBROWNFOXJUMPEDOVERTHELAZYDOGSend
Sample Output
65144
Hint
In the first test case, the spam encoding of ‘BU
’ is ‘|3|_|
’. The 6 plain text messages with this spam encoding are ‘BU
’, ‘IEU
’, ‘BIJ
’, ‘IEIJ
’, ‘BLI
’, and ‘IELI
’. In the second test case, the spam encoding of ‘UJ
’ is ‘|_|_|
’. The 5 plain text messages with this spam encoding are ‘UJ
’, ‘LU
’, ‘IJJ
’, ‘LLI
’, and ‘LIJ
’.
Source
代码:
#include <string.h>
char * letter[]=...{
"4", "|3", "(", "|)", "3", "|=", "6", "#", "|", "_|", "|<", "|_", "|//|",
"|/|", "0", "|0", "(,)", "|?", "5", "7", "|_|", "//", "////", "><", "-/", "2"
};
char str[401];
int num[401];
//reutrn 0-false ,1-true
int cmp(char * cs,char * ps,int size)
...{
int i;
for(i=0;i<size;i++)
...{
if(*cs!=*ps) return 0;
cs++;
ps++;
}
return 1;
}
int main()
...{
char tmp[101];
char * p,*q;
int i,j,len,ll;
while(1)
...{
gets(tmp);
if(strcmp(tmp,"end")==0)
break;
for(p=tmp,q=str;*p;p++)
...{
strcpy(q,letter[*p-'A']);
q+=strlen(letter[*p-'A']);
}
memset(num,0,401*sizeof(int));
num[0]=1;
len=strlen(str);
for(i=1;i<=len;i++)
...{
for(j=0;j<26;j++)
...{
ll=strlen(letter[j]);
p=str+i-ll;
if(i>=ll&&cmp(p,letter[j],ll))
...{
num[i]+=num[i-ll];
}
}
}
printf("%d ",num[len]);
}
return 0;
}
- POJ 3073
- poj 3073 Spam
- POJ 3073 Spam 笔记
- POJ
- poj
- POJ
- POJ
- poj
- poj
- POJ
- POJ
- poj
- POJ
- POJ
- POJ
- POJ
- POJ
- POJ
- javascript中的枚举如何定义的?
- SQL Server 2005中的except和INTERSECT运算
- 在ASP.NET中长内容自动分页的实现
- SQL语句:Group By 语句小结
- c sharp 是未来吗
- POJ 3073
- 中国聚客网[http://www.crossgo.com]正式开通拉!
- 编写Enterprise bean的客户端
- 小识Windows 批处理文件
- 关于加密和安全
- MFC+ADO+ACCESS创建数据库
- struts的信息提示
- ASCII码表
- 《反转棋盘》解答