古代密码 字符串水题
2016-11-09 17:43
225 查看
原题传送门
题目描述
吐槽
正经的题解
听说NOI题库又开始加题了2333,对于它的题目质量我不做任何评价
method to encrypt a string.
The first one was replacing, which replaced every character by another. It
should use a conversion table to map the original letters to the encryped
letters. For example, if the conversion table was “ABCDEFGHIJKLMNOPQRSTUVWXYZ”
to “BCDEFGHIJKLMNOPQRSTUVWXYZA” and the original string was “HELLO”, the
encryped string should be “IFMMP”.
The second one was reodering. It should use a reordering table such as
<2, 1, 5, 4, 3, 7, 6, 10, 9, 8>. Apply it to the original string
“VICTORIOUS”, we got “IVOTCIRSUO” as the encrypted string.
Now, give you an original string and an encryped string. Your task is to
answer whether the original string can be converted to the encryped string using
replacing AND reodering.
PS:其实可以把每个单词中字母的数量统计出来然后排个序再处理,,然而数据范围太小了,,省了,,
题目描述
吐槽
正经的题解
听说NOI题库又开始加题了2333,对于它的题目质量我不做任何评价
原题传送门
题目描述:
In ancient wars, cryptogram was applied widely. There were two types ofmethod to encrypt a string.
The first one was replacing, which replaced every character by another. It
should use a conversion table to map the original letters to the encryped
letters. For example, if the conversion table was “ABCDEFGHIJKLMNOPQRSTUVWXYZ”
to “BCDEFGHIJKLMNOPQRSTUVWXYZA” and the original string was “HELLO”, the
encryped string should be “IFMMP”.
The second one was reodering. It should use a reordering table such as
<2, 1, 5, 4, 3, 7, 6, 10, 9, 8>. Apply it to the original string
“VICTORIOUS”, we got “IVOTCIRSUO” as the encrypted string.
Now, give you an original string and an encryped string. Your task is to
answer whether the original string can be converted to the encryped string using
replacing AND reodering.
吐槽:
果然是NOI题库的风格,这个鬼中文题目看了三遍都没看懂它是啥意思,还是英文题目稍微靠谱点,,正经的题解:
题目中所说的改变和交换其实都是任意的,,通俗点说,,想怎么换就怎么换。。所以,根本就没有任何必要来考虑题目中所说的交换,直接统计单词的个数然后进行判断即可PS:其实可以把每个单词中字母的数量统计出来然后排个序再处理,,然而数据范围太小了,,省了,,
#include <cstdio> #include <cstring> #include <algorithm> char s1[1500], s2[1500]; int sum1[50], sum2[50]; int main () { scanf("%s %s", s1, s2); int len1 = strlen(s1); for (int i = 0; i < len1; i++) sum1[(int)s1[i] - 'A' + 1]++; int len2 = strlen(s2); for (int i = 0; i < len2; i++) sum2[(int)s2[i] - 'A' + 1]++; for (int i = 1; i <= 26; i++) { for (int j = 1; j <= 26; j++) if (sum1[i] == sum2[j]) { sum1[i] = 0; sum2[j] = 0; break; } if (sum1[i] > 0) { printf("NO"); exit(0); } } printf("YES"); return 0; }
相关文章推荐
- 古代密码 字符串水题
- 古代密码 字符串水题
- 古代密码 字符串水题
- 古代密码 字符串水题
- 古代密码 字符串水题
- 古代密码 字符串水题
- 古代密码 字符串水题
- 古代密码 字符串水题
- 古代密码 字符串水题
- 古代密码 字符串水题
- 古代密码 字符串水题
- 古代密码 字符串水题
- 古代密码 字符串水题
- 古代密码 字符串水题
- OpenJudge百炼-2820-古代密码-C语言-字符串处理
- 【数据结构】第3周 字符串 3:古代密码
- 成长轨迹47 【ACM算法之路 百炼poj.grids.cn】【字符串处理】【2820:古代密码】
- Microsoft.Jet.OLEDB.4.0数据库连接字符串中密码的写法!
- 字符串 密码加密解密
- C#正则表达式检测字符串(密码强度)