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. Sparrow - Distributed, Low Latency Scheduling

    http://www.cs.berkeley.edu/~matei/papers/2013/sosp_sparrow.pdf http://www.eecs.berkeley.edu/~keo/tal ...

  2. 提交任务到spark master -- 分布式计算系统spark学习(四)

    部署暂时先用默认配置,我们来看看如何提交计算程序到spark上面. 拿官方的Python的测试程序搞一下. qpzhang@qpzhangdeMac-mini:~/project/spark-1.3. ...

  3. (3.15)常用知识-sql server分页

    推荐使用row_number over()方法,或2012以上使用offset PageSize = PageNumber = 方法一:(最常用的分页代码, top / not in) UserId ...

  4. python学习笔记(二十)初识面向对象

    面向对象的编程的主要思想是把构成问题的各个事物分解成各个对象,建立对象的目的不是为了完成一个步骤,而是为了描述一个事物在解决问题的过程中经历的步骤和行为.对象作为程序的基本单位,将程序和数据封装其中, ...

  5. linux内核介绍

    linux系统可以分为:包括用户空间和内核空间两个部分. 现代cpu通常实现了不同的工作模式,以ARM为例,实现了7种工作模式: 用户模式.快速中断.外部中断.管理模式.数据访问中止.系统模式.未定义 ...

  6. FTP服务器文件上传的代码实现

    方式一: @Test public void testFtpClient() throws Exception { // 1.创建一个FtpClient对象 FTPClient ftpClient = ...

  7. dbms_advisor 手动生成段顾问建议!

    执行包需要dbms_advisor权限: sys@ORCL> grant advisor to u1; 授权成功. 创建段顾问任务,指定create_task的advisor_name参数为“段 ...

  8. usr/bin/ld: cannot find 错误解决方法和 /etc/ld.so.conf

    我makefile出现这个错误: HelloWorldServer.c:(.text+0xaa): undefined reference to `zmq_send'collect2: error: ...

  9. android 显示internet 图片

    try { HttpGet httpRequest = new HttpGet(edtUrl.getText() .toString()); HttpClient httpclient = new D ...

  10. XDU 1032

    #include<cstdio> typedef long long ll; ; ll feima(ll a,ll b) { ll c=; while(b) { ) c=c*a%mod; ...