2017-08-31 20:11:39

writer:pprp

一开始说好这个是个水题,就按照水题的想法来看,唉~

最后还是懵逼了,感觉太复杂了,一开始想要排序两串字符,然后移动之类的,但是看了看

好像没有什么规律...

然后就去膜大神code了

其实转换了一个思路,对两个字符串分别统计每个的个数,

然后分别排序,如果每个个数都可以对的上就说明可以通过两个操作得到

代码如下:

/*
@theme:poj 2159 ancient cipher
@writer:pprp
@declare:
@begin:19:20
@end:20:07
@date:2017/8/31
*/ #include <iostream>
#include <algorithm>
#include <cstdio> using namespace std; int main()
{
//freopen("in.txt","r",stdin);
ios::sync_with_stdio(false); int a[] = {};
int b[] = {}; string str1, str2; cin >> str1 >> str2; for(int i = ; i < str1.length() ; i++)
a[str1[i] - 'A']++;
for(int i = ;i < str2.length() ; i++)
b[str2[i] - 'A']++; sort(a,a+);
sort(b,b+); int i;
for(i = ; i < ; i++)
if(a[i] != b[i])
break; if(i != )
cout << "NO" << endl;
else
cout << "YES" << endl; return ;
}

英语:

encrypted 加密
eavesdrop 偷听
cipher 密码
substitute 代替
permutation 变换组合

POJ2159 ancient cipher - 思维题的更多相关文章

  1. uvaoj1339 - Ancient Cipher(思维题,排序,字符串加密)

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  2. UVa 1339 Ancient Cipher --- 水题

    UVa 1339 题目大意:给定两个长度相同且不超过100个字符的字符串,判断能否把其中一个字符串重排后,然后对26个字母一一做一个映射,使得两个字符串相同 解题思路:字母可以重排,那么次序便不重要, ...

  3. POJ2159 Ancient Cipher

    POJ2159 Ancient Cipher Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 38430   Accepted ...

  4. UVa LA 3213 - Ancient Cipher 水题 难度: 0

    题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...

  5. 思维题:UVa1334-Ancient Cipher

    Ancient Cipher Ancient Roman empire had a strong government system with various departments, includi ...

  6. UVa1399.Ancient Cipher

    题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  7. Ancient Cipher UVa1339

    这题就真的想刘汝佳说的那样,真的需要想象力,一开始还不明白一一映射是什么意思,到底是有顺序的映射?还是没顺序的映射? 答案是没顺序的映射,只要与26个字母一一映射就行 下面给出代码 //Uva1339 ...

  8. uva--1339 - Ancient Cipher(模拟水体系列)

    1339 - Ancient Cipher Ancient Roman empire had a strong government system with various departments, ...

  9. zoj 3778 Talented Chef(思维题)

    题目 题意:一个人可以在一分钟同时进行m道菜的一个步骤,共有n道菜,每道菜各有xi个步骤,求做完的最短时间. 思路:一道很水的思维题, 根本不需要去 考虑模拟过程 以及先做那道菜(比赛的时候就是这么考 ...

随机推荐

  1. Spark 源码分析 -- Stage

    理解stage, 关键就是理解Narrow Dependency和Wide Dependency, 可能还是觉得比较难理解 关键在于是否需要shuffle, 不需要shuffle是可以随意并发的, 所 ...

  2. 前端开发 - HTML - 总结

    html head标签 title 显示网站的标题 meta 提供有关页面的原信息 link 链接css资源文件.网站图标 style 定义内部样式表 script 链接脚本js文件 body标签 块 ...

  3. thinkphp curd的事务回滚 一看就会

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/qq1355541448/article/details/32314403     /**       ...

  4. IOS中程序如何进行推送消息(本地推送,远程推送)2(下)

    内容中包含 base64string 图片造成字符过多,拒绝显示

  5. docker——容器(container)

    容器相关命令一览表: docker create docker run docker start/stop/restart docker attach/exec docker rm docker ex ...

  6. delphi 正则表达式

    常用正则表式 正则表达式用于字符串处理.表单验证等场合,实用高效.现将一些常用的表达式收集于此,以备不时之需. 匹配中文字符的正则表达式: [\u4e00-\u9fa5] 评注:匹配中文还真是个头疼的 ...

  7. C# comport 打印图像

    public string GetLogo() { string logo = ""; if (!File.Exists(@"C:\bitmap.bmp")) ...

  8. fake-useragent,python爬虫伪装请求头

    在编写爬虫进行网页数据的时候,大多数情况下,需要在请求是增加请求头,下面介绍一个python下非常好用的伪装请求头的库:fake-useragent,具体使用说明如下: 1.在scrapy中的使用 第 ...

  9. 下拉刷新&上拉加载

    效果演示 核心codehtml <ion-view view-title="学生list"> <ion-content > <ion-refreshe ...

  10. DevStore分享:月薪3万的程序员都避开了哪些坑

    程序员薪水有高有低,有的人一个月可能拿30K.50K,有的人可能只有2K.3K.同样有五年工作经验的程序员,可能一个人每月拿20K,一个拿5K.是什么因素导致了这种差异?我特意总结了容易导致薪水低的九 ...