Ancient Cipher
来源:互联网 发布:知已知彼百战不殆 编辑:程序博客网 时间:2024/06/04 21:49
Ancient Cipher
think:
我记得心理老师曾经说过,人在高兴的时候,应该多做一些平时想做却没有做的事情,不然,就是浪费了这样的好心情。
所以啊,我就把将近两个月前的没有AC的题目拿出来了,也是该晾一晾了……
回归这道题目,这是一个类似于映射的问题,两个字符串,计算每个字符出现的个数,然后排序,比较。
题目比较难理解,但是代码很容易实现。
#include <iostream>#include <cstdio>#include <algorithm>#include <cstring>using namespace std;char s1[121], s2[121];int a[200], b[200];int main(){ while(~scanf("%s%s", s1, s2)) { memset(a, 0, sizeof(a)); memset(b, 0, sizeof(b)); int len1 = strlen(s1); for(int i=0;i<len1;i++) { a[s1[i]]++; b[s2[i]]++; } sort(a, a+200); sort(b, b+200); int f = 0; for(int i=0;i<200;i++) { if(a[i]!=b[i]) { f = 1; break; } } if(f) cout<<"NO"<<endl; else cout<<"YES"<<endl; } return 0;}
阅读全文
0 0
- Ancient Cipher
- Ancient Cipher
- Ancient Cipher
- Ancient Cipher
- Ancient Cipher
- Ancient Cipher
- Ancient Cipher
- POJ2159 Ancient Cipher
- Ancient Cipher--POJ2159
- POJ 2159 Ancient Cipher
- poj 2159 : Ancient Cipher
- POJ 2159 Ancient Cipher
- POJ 2159 Ancient Cipher
- poj 2159 Ancient Cipher
- ZOJ 2658 Ancient Cipher
- POJ2159 Ancient Cipher
- POJ 2159 Ancient Cipher
- POJ2159 Ancient Cipher
- 解决IIS+PHP出现的“500
- 7. Reverse Integer
- Java基础教程18-方法传参和返回值
- Lecture 2: Supervised machine learning
- http协议无状态中的 "状态" 到底指的是什么?!
- Ancient Cipher
- 程序员面试金典——实时中位数_
- vue2.0实战案例之高级教程-老孟编程
- 四、5、Date类型及方法
- POJ3155_Hard Life_二分求解分数规划||最大权闭合图
- POJ 1969 Count on Canton 笔记
- 文章标题
- 如何解决loadrunner回放日志中的乱码问题
- android 图片转换