uva1339 - Ancient Cipher
来源:互联网 发布:微信开发java教程 编辑:程序博客网 时间:2024/05/22 12:02
题意:
两字符串,求它们之间的26字母能否一一对应。
思路:
题目即求是否会有一个映射关系,若A->C,则所有A->C,这样实际上只要两个串相同字符数目是否能够一一对应即可。
代码如下:
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int N = 105;char stra[N], strb[N];int cnta[30], cntb[30];int main() { while (~scanf("%s%s",stra,strb)) { memset(cnta, 0, sizeof(cnta)); memset(cntb, 0, sizeof(cntb)); int a = strlen(stra); for (int i = 0; i < a; i++) { cnta[stra[i] - 'A']++; cntb[strb[i] - 'A']++; } sort(cnta, cnta + 26); sort(cntb, cntb + 26); int i; for (i = 0; i < 26; i++) if (cnta[i] != cntb[i]) break; if (i>=26) printf("YES\n"); else printf("NO\n"); }}
0 0
- Uva1339 Ancient Cipher
- Uva1339 - Ancient Cipher
- UVA1339- Ancient Cipher
- UVA1339-Ancient Cipher
- UVa1339 - Ancient Cipher
- uva1339 - Ancient Cipher
- UVa1339 Ancient Cipher
- UVa1339 Ancient Cipher
- Ancient Cipher(Uva1339)
- UVa1339-Ancient Cipher
- UVa1339 Ancient Cipher
- UVA1339 Ancient Cipher(排序)
- Ancient Cipher,NEETC 2004,UVa1339
- 例题4-1 UVa1339 Ancient Cipher
- UVA1339 UVALive3213 POJ2159 ZOJ2658 Ancient Cipher
- Ancient Cipher
- Ancient Cipher
- Ancient Cipher
- 在Ubuntu14.04中安装ROS Indigo
- ZOJ1025 Wooden Sticks
- 数据结构 栈和队列
- 2016蓝桥杯算法训练——最大最小公倍数
- Light OJ 1170 Counting Perfect BST (DP+数学)
- uva1339 - Ancient Cipher
- Building Maintainable Software-java篇之Separate Concerns in Modules
- 杭电1000:A + B Problem
- 299. Bulls and Cows
- 《IP地址介绍及为linux配置IP地址》
- 关于Runloop 补充-1(相关文档)
- 利用VPS搭建VPN
- [leetcode] 56. Merge Intervals 解题报告
- hdu 5299 Circles Game