POJ2159 ancient cipher - 思维题
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 - 思维题的更多相关文章
- uvaoj1339 - Ancient Cipher(思维题,排序,字符串加密)
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- UVa 1339 Ancient Cipher --- 水题
UVa 1339 题目大意:给定两个长度相同且不超过100个字符的字符串,判断能否把其中一个字符串重排后,然后对26个字母一一做一个映射,使得两个字符串相同 解题思路:字母可以重排,那么次序便不重要, ...
- POJ2159 Ancient Cipher
POJ2159 Ancient Cipher Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 38430 Accepted ...
- UVa LA 3213 - Ancient Cipher 水题 难度: 0
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- 思维题:UVa1334-Ancient Cipher
Ancient Cipher Ancient Roman empire had a strong government system with various departments, includi ...
- UVa1399.Ancient Cipher
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- Ancient Cipher UVa1339
这题就真的想刘汝佳说的那样,真的需要想象力,一开始还不明白一一映射是什么意思,到底是有顺序的映射?还是没顺序的映射? 答案是没顺序的映射,只要与26个字母一一映射就行 下面给出代码 //Uva1339 ...
- uva--1339 - Ancient Cipher(模拟水体系列)
1339 - Ancient Cipher Ancient Roman empire had a strong government system with various departments, ...
- zoj 3778 Talented Chef(思维题)
题目 题意:一个人可以在一分钟同时进行m道菜的一个步骤,共有n道菜,每道菜各有xi个步骤,求做完的最短时间. 思路:一道很水的思维题, 根本不需要去 考虑模拟过程 以及先做那道菜(比赛的时候就是这么考 ...
随机推荐
- python的@classmethod和@staticmethod
本文是对StackOverflow上的一篇高赞回答的不完全翻译,原文链接:meaning-of-classmethod-and-staticmethod-for-beginner Python面向对象 ...
- 剑指Offer——和为S的连续正数序列
题目描述: 小明很喜欢数学,有一天他在做数学作业时,要求计算出9~16的和,他马上就写出了正确答案是100.但是他并不满足于此,他在想究竟有多少种连续的正数序列的和为100(至少包括两个数).没多久, ...
- Python并行编程(七):线程同步之事件
1.基本概念 事件是线程之间用于通讯的对象.有的线程等待信号,有的线程发出信号.基本上事件对象都会维护一个内部变量,可以通过set方法设置为true,也可以通过clear方法设置为false.wait ...
- Keras + Ubuntu环境搭建
安装Theano (环境参数:Ubuntu 16.04.2 Python 2.7) 安装 numpy 和 scipy 1.sudo apt-get install python-numpy pyth ...
- (2.10)备份与还原--利用T-SQL进行备份还原
常用: /************ 一.数据库备份 ************/ with init,format,stats=1init:覆盖format:格式化备份集stats=1:显示进度条 ST ...
- git获取远程仓库代码
首先在本地创建一个目录“ MyProject”,用来存放工程文件,git进入该文件夹,执行 git clone 远程项目MyCode地址 将代码克隆到本地然后进入“MyCode”文件夹下 cd MyC ...
- SDUT中大数实现的题目,持续更新(JAVA实现)
SDUT2525:A-B (模板题) import java.util.Scanner; import java.math.*; public class Main { public static v ...
- Redis操作手册
一.Redis简介 1.1 NoSQL NoSQL,泛指非关系型数据库,NoSQL数据库分为四大类:键值存储数据库(Redis,Voldemort,Oracle BDB).列存储数据库(HBase,R ...
- std::bind
参考资料 • cplusplus.com:http://www.cplusplus.com/reference/functional/bind/ • cppreference.com:http://e ...
- centos7安装rabbitmq并简单使用
先安装erlang rpm -Uvh http://www.rabbitmq.com/releases/erlang/erlang-18.1-1.el7.centos.x86_64.rpm 安装rab ...