1339 - Ancient Cipher Ancient Roman empire had a strong government system with various departments, including a secret service department. Important documents were sent between provinces and the capital in encrypted form to prevent eavesdropping. The…
UVa 1339 题目大意:给定两个长度相同且不超过100个字符的字符串,判断能否把其中一个字符串重排后,然后对26个字母一一做一个映射,使得两个字符串相同 解题思路:字母可以重排,那么次序便不重要,可以分别统计两个字符串中的各个字母出现的次数,得到两个cnt[26]数组, 又由于可以进行映射,则可以直接对两个数组进行排序后判断是否相等(相当于原来相等的值的两个地方做映射) /* UVa 1339 Ancient Cipher --- 水题 */ #include <cstdio> #incl…
大意:读入两个字符串(都是大写字母),字符串中字母的顺序可以随便排列.现在希望有一种字母到字母的一一映射,从而使得一个字符串可以转换成另一个字符串(字母可以随便排列)有,输出YES:否,输出NO:exp: 输入HAHAHEHE 输出YES 可以将A→E,或E→A: 关键在于,问题简化:因为不用考虑字母位置,所以可以分别统计两个字符串中不同字母出现次数,计入数组counts1和counts2.那么,怎么知道谁和谁对应呢?这里面有个隐含条件:如果A→B,那么A在1数组出现的次数和B在2数组中出现的次…
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4085 13855995 1339 Ancient Cipher Accepted C++ 0.012 2014-07-09 12:35:33 Ancient Cipher Ancient Roman empire had a strong government system wit…
1.链接地址: http://poj.org/problem?id=2159 http://bailian.openjudge.cn/practice/2159 2.题目: Ancient Cipher Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 28064   Accepted: 9195 Description Ancient Roman empire had a strong government system…
这题就真的想刘汝佳说的那样,真的需要想象力,一开始还不明白一一映射是什么意思,到底是有顺序的映射?还是没顺序的映射? 答案是没顺序的映射,只要与26个字母一一映射就行 下面给出代码 //Uva1339 //Ancient Cipher //easy #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int main() { freopen("Ancient.i…
Ancient Cipher Description Ancient Roman empire had a strong government system with various departments, including a secret service department. Important documents were sent between provinces and the capital in encrypted form to prevent eavesdropping…
POJ2159 Ancient Cipher Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 38430   Accepted: 12515 Description Ancient Roman empire had a strong government system with various departments, including a secret service department. Important doc…
2017-08-31 20:11:39 writer:pprp 一开始说好这个是个水题,就按照水题的想法来看,唉~ 最后还是懵逼了,感觉太复杂了,一开始想要排序两串字符,然后移动之类的,但是看了看 好像没有什么规律... 然后就去膜大神code了 其实转换了一个思路,对两个字符串分别统计每个的个数, 然后分别排序,如果每个个数都可以对的上就说明可以通过两个操作得到 代码如下: /* @theme:poj 2159 ancient cipher @writer:pprp @declare: @be…
Ancient Cipher Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 36074   Accepted: 11765 Description Ancient Roman empire had a strong government system with various departments, including a secret service department. Important documents w…
  Ancient Roman empire had a strong government system with various departments, including a secret service department. Important documents were sent between provinces and the capital in encrypted form to prevent eavesdropping. The most popular cipher…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 位置其实都没关系了. 只要每个字母都有对应的字母,它们的数量相同就可以了. 求出每种字母的数量. 排序之后. 肯定是要一一对应的. [代码] #include <bits/stdc++.h> using namespace std; string s1,s2; map <int,int> mmap1,mmap2; vector <int> v1,v2; int main(){ #ifdef LOCAL_…
题 题意 给你一个只含CHON的有机物的化学式如C6H5OH求相对分子质量 分析 ... 代码 switch #include<cstdio> #include<cctype> int t; double w,m[5]= {12.01,1.008,16.00,14.01}; char s[100]; void add(int f,int i) { if(isdigit(s[i+1])) if(isdigit(s[i+2])) w+=m[f]*((s[i+1]-'0')*10+s[i…
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1214 题意 问字符串a能否是字符串b经过某种替换+移位密码的密文 思路 明显,计数对的上就行 刘书题目描述不全面 代码 #include <algorithm> #include <cassert> #include <cmath>…
Ancient Roman empire had a strong government system with various departments, including a secret service department. Important documents were sent between provinces and the capital in encrypted form to prevent eavesdropping. The most popular ciphers…
Ancient Roman empire had a strong government system with various departments, including a secret service department. Important documents were sent between provinces and the capital in encrypted form to prevent eavesdropping. The most popular ciphers…
题目链接:https://uva.onlinejudge.org/external/13/1339.pdf 紫书P73 解题报告: #include <stdio.h> #include <string.h> #include <stdlib.h> #include <algorithm> using namespace std; int main() { //freopen("input.txt","r",stdin…
Description Ancient Roman empire had a strong government system with various departments, including a secret service department. Important documents were sent between provinces and the capital in encrypted form to prevent eavesdropping. The most popu…
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2151 题意 麻将,有13张牌,问再加哪一张牌可以凑成一对,若干个三张和若干个三联. 思路 如刘书思路,明显,这是一道模拟题. 感想 1. 三倍ice cream! 代码 #include <algorithm> #include <cassert> #incl…
UVA 1156 - Pixel Shuffle 题目链接 题意:依据题目中的变换方式,给定一串变换方式,问须要运行几次才干回复原图像 思路:这题恶心的一比,先模拟求出一次变换后的相应的矩阵,然后对该矩阵求出全部循环长度,全部循环长度的公倍数就是答案 代码: #include <stdio.h> #include <string.h> const int N = 1100; int t, n, g[N][N], vis[N][N], save[N][N]; char str[N],…
内容: Ancient Roman empire had a strong government system with various departments, including a secret service department. Important documents were sent between provinces and the capital in encrypted form to prevent eavesdropping. The most popular ciph…
题目大意:给出i,输出第i个镜像数,不能有前导0. 题解:从外层开始模拟 #include <stdio.h> int p(int x) { int sum, i; ;i<=x;i++) sum *= ; return sum; } int main() { ], c; while(~scanf("%d", &n)) { ) break; i=; *p((i-)/)) { n -= *p((i-)/); i++; } c = (i+)/; t=; while(…
题意:有一颗二叉树,深度为D,所有节点从上到下从左到右编号为1,2,3.....在结点一处放一个小球,每个节点是一个开关,初始全是关闭的,小球从顶点落下,小球每次经过开关就会把它的状态置反,现在问第k个球下落到D层时经过的开关编号 思路:lrj大哥的书上第一种方法是模拟,但是还是有要知道的知识点,对于一个结点k,其左子结点为2k,右结点为2k+1,它的父节点为k/2,深度为d的一颗树包含2^d个结点: 第二种方法,由于第一中方法模拟的运算量太大,所以我们lrj大哥说当I是奇数时,它是往左走的第(…
●赘述题意 给出一个中国象棋残局,告诉各个棋子的位置,黑方只有1枚“将”,红方有至少2枚,至多7枚棋子,包含1枚“帅G”,和若干枚“车R”,“马H”,“炮C”.当前为黑方的回合,问黑方的“将”能否在移动一步后不被“将军”. ●题解 本题就是一个模拟:枚举“将”向四个方向走,是否满足题意. 但比较考察逻辑和代码能力. 但有一个坑点: “将”在移动时,不能移动到与“帅”照面. 但,恶心的数据会有输入的局面就出现将帅照面的情况,按理说,应是黑方赢了(因为轮到黑方的回合),也就是说在程序中加一个特判.但…
题意:阅读理解难度一道比一道难orz.手摸了好久样例 题解: 读入:大循环用getline读入header顺便处理一下,  里面再写两重循环,外层一次读三个串,内层一次读num个串. 之后就查表,线性输出即可. 关于判断11111,我用了换底公式:log(id + 1) / log(2) == num + 1 && pow(2, log(id + 1) / log(2)) 关于读入,我写了个getnchar的函数,封装一下getchar() 虽然是final模拟(签到orz)题,码量不大嘛…
In order to understand early civilizations, archaeologists often study texts written in ancient languages.One such language, used in Egypt more than 3000 years ago, is based on characters called hieroglyphs.Figure C.1 shows six hieroglyphs and their…
题意:一个迷宫,每个交叉路口有一路标,限制了你从某方向进入该路口所能进入的路口. 题解:1.对于方向的处理:将node多增加一维dir,通过一个const 字符数组 加 上dir_id函数 以及一个方向数组 快速完成从读取字母到模拟路口限制的转换. 2.用一个四位数组记录某节点某方向是否能走,     3.对于路径的记录,用node p[] 记录当前节点的前一个节点,然后将其中的元素push到一个vector里面再输出. 坑:1.no possible input 多了个空格(紫书上没有前缀空格…
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4085 两个字符串,判断能否把其中一个字符串重排,然后对每个字母进行映射(比如映射到前一个字母),使得两个字符串相同 这里要转一个弯,既然字母可以重排,那么每个字母最初的顺序并不重要,重要的是每个字母出现的次数,所以只要分别用数组保存每个字母出现的次数,在把这个数组从小到大排序,如果最后两个…
题目链接 题意:一张纸,每次从右往左对折.折好以后打开,让每个折痕都自然的呈90度.输出形状. 思路:模拟折……每次折想象成把一张纸分成了正面在下的一张和反面在上的一张.维护左边和方向,然后输出.细节有点多. 代码: #include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> using namespace std; #define N (1<<13)+…
题意:给定一个错误代码,让你修改数据,使得它能够输出正确答案,错误代码是每次取最短的放入. 析:那么我们就可以模拟这个过程,然后修改每条边的权值,使得它能输出正确答案. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #i…