POJ 2159 Ancient Cipher

嵌入式学习(29)-ASM330LHH驱动程序 ASM330LHH是一种系统级封装器件,具有3D数字加速度计和3D数字陀螺仪,扩展温度范围上限为+105 °C,适用于汽车非安全领域的应用。ASM330LHH 的满量程加速范围为±2 g、±4 g、±8 g 和 ±16 g,角速度范围扩展至 ±125 dps、±250 dps、±500 dps、±1000 dps、± 2000 dps 和 ±4000 dps,适合各种汽车应用。 阅读详情

POJ  2159  Ancient Cipher

 

Ancient Cipher

Time Limit: 1000MS

Memory Limit: 65536K

Total Submissions: 35432

Accepted: 11550

Description

Ancient Romanempire had a strong government system with various departments, including asecret service department. Important documents were sent between provinces andthe capital in encrypted form to prevent eavesdropping. The most popularciphers in those times were so called substitution cipher and permutationcipher. 
Substitution cipher changes all occurrences of each letter to some otherletter. Substitutes for all letters must be different. For some letterssubstitute letter may coincide with the original letter. For example, applyingsubstitution cipher that changes all letters from 'A' to 'Y' to the next onesin the alphabet, and changes 'Z' to 'A', to the message "VICTORIOUS"one gets the message "WJDUPSJPVT". 
Permutation cipher applies some permutation to the letters of the message. Forexample, applying the permutation <2, 1, 5, 4, 3, 7, 6, 10, 9, 8> to themessage "VICTORIOUS" one gets the message"IVOTCIRSUO". 
It was quickly noticed that being applied separately, both substitution cipherand permutation cipher were rather weak. But when being combined, they werestrong enough for those times. Thus, the most important messages were firstencrypted using substitution cipher, and then the result was encrypted usingpermutation cipher. Encrypting the message "VICTORIOUS" with thecombination of the ciphers described above one gets the message"JWPUDJSTVP". 
Archeologists have recently found the message engraved on a stone plate. At thefirst glance it seemed completely meaningless, so it was suggested that themessage was encrypted with some substitution and permutation ciphers. They haveconjectured the possible text of the original message that was encrypted, andnow they want to check their conjecture. They need a computer program to do it,so you have to write one.

Input

Input contains twolines. The first line contains the message engraved on the plate. Beforeencrypting, all spaces and punctuation marks were removed, so the encryptedmessage contains only capital letters of the English alphabet. The second linecontains the original message that is conjectured to be encrypted in themessage on the first line. It also contains only capital letters of the Englishalphabet. 
The lengths of both lines of the input are equal and do not exceed 100.

Output

Output"YES" if the message on the first line of the input file could be theresult of encrypting the message on the second line, or "NO" in theother case.

Sample Input

JWPUDJSTVP

VICTORIOUS

Sample Output

YES

 

 

本题需要注意到substitution cipher不仅仅只有平移的方式…所以只需要统计一下两个字符串中字母出现的频率,如果相等即为YES;

 

代码:

//poj 2159c Ancient Cipher

#define LOCAL

#include <cstdio>

#include <string>

#include <algorithm>

int main(){

    #ifdef LOCAL

    freopen("in.txt","r",stdin);

    #endif

    int letter1[26],letter2[26];

    memset(letter1,0,sizeof letter1);

    memset(letter2,0,sizeof letter2);

    char message[200],encrypted[200];

    scanf("%s",encrypted)!

    for(int i=0;message[i];i++) letter1[message[i]-'A']++;

    scanf("%s",encrypted);

    for(int i=0;encrypted[i];i++) letter2[encrypted[i]-'A']++;

    sort(letter1,letter1+26);

    sort(letter2,letter2+26);

    for(int i=0;i<26;i++)

        {if(letter1[i]!=letter2[i]) printf("NO\n");return 0}

    printf("YES\n");

   

    return 0

}

 

使用 Azure DevSecOps 和 AIOps 构建可扩展且安全的多区域金融科技 SaaS 平台 这家虚构的金融科技 SaaS 组织在 Microsoft Azure 上构建了一个现代化的多区域架构,以实现高可用性、主动安全性和简化的 DevSecOps 工作流。如果您是 DevOps 从业者、SRE 专业人士或致力于创建弹性、可扩展且安全的金融科技解决方案的技术领导者,您将从中获得可直接应用于您自身项目的见解和经验教训。与大多数快速扩张的金融科技公司一样,他们需要确保不间断的正常运行时间、坚不可摧的安全性以及快速的功能交付,以满足全球用户群的需求。即使是短暂的中断也会损害用户的信心和忠诚度。 阅读详情

相关推荐

实战避坑:泛微E9流程接口与单点登录(SSO)开发全解析(含自定义Action、Restful API与免密登录)

本文深入解析泛微E9流程接口与单点登录(SSO)开发中的关键技术与避坑指南,涵盖自定义Action开发、Restful API鉴权机制及跨系统单点登录实现。通过实战案例与代码示例,帮助开发者高效完成二次开发,解决系统集成中的数据孤岛问题,提升企业信息化建设效率。

weixin_42549451的博客 674

poj2159 Ancient Cipher

POJ2159 Ancient Cipher 一道简单的字符串处理题,其实只要读懂题意,就不难想出算法。对于一般的字符串处理题其实大多可以用hash来处理,故下面采用一种字符串hash的方法 var s1,s2:string;i,hash1,hash2:longint; h1,h2:array[0..26]of longint; begin readln(s1); readln(s2)

Seeker 544

手把手教你用示波器抓取MIPI D-PHY波形:从LP11到HS Burst的完整信号解析

本文详细介绍了使用示波器精准捕获MIPI D-PHY信号的关键技巧,包括探头选择、示波器参数设置、信号状态解析及高级触发配置。通过实战案例和波形分析,帮助工程师快速识别从LP11到HS Burst的各种信号状态,解决常见的信号完整性问题,提升调试效率。

weixin_30471561的博客 561

POJ2159——Ancient Cipher

题目链接:http://poj.org/problem?id=2159 Ancient Cipher 解题思路:题目很坑,我开始就以为是每个字母都是加上或减去同一个数,然后经过某种变换得出的。然后这个变换,我想了好久,最后还是经队友的提醒才知道,无论字母变成什么,它的频数是不会变得,最后根据它的频数求解即可!!! #include #include #include #include #

piaocoder 514

用Python+OpenCV给斗地主做个‘外挂’:手把手教你写个桌面记牌器(附源码)

本文详细介绍了如何使用Python和OpenCV开发一个智能斗地主记牌器,包括环境搭建、图像采集与预处理、扑克牌识别技术及PyQt5界面设计。通过实战案例,帮助开发者掌握图像处理与界面开发的结合应用,提升游戏辅助工具的编写能力。

weixin_29079643的博客 546

DSH-Work:一个让DeepSeek下载即用的Harness客户端

使用大模型工具时,环境配置往往比模型本身更让人头疼。DeepSeek Harness作为一类封装层,将模型调用、上下文管理、参数控制等复杂细节统一收拢,对外提供简洁操作入口。开源的DSH-Work正是这样一款Harness客户端,它通过自带运行时与保守默认配置,实现了下载即用、免配环境的目标,让使用者无需掌握Python、CUDA等专业知识即可快速连接DeepSeek云端或本地服务。对于非技术背景的用户,它降低了AI工具的使用门槛;对于开发者,它把时间从环境排错中解放出来,更专注于提示词调优与工作流设计。无

weixin_29048309的博客 344

思维-POJ 2159-Ancient Cipher

思维-POJ 2159-Ancient Cipher 题目链接: Ancient Cipher 思路: 题目大意: 给出两种对文件加密的方式,替换和重新排列 替换:例如:替换规则可以是将'A' 到 'Y'替换成它的下一个字符,将'Z'替换成 'A',如果原词是 "VICTORIOUS" 则它变成 "WJDUPSJPVT" 重新排列:排列方法改变原来单词中字母的顺序。...

[SZU_Crayon] 484

基于Python的股票K线图爬取与形态识别系统

本文详细介绍了一个基于Python的股票K线图爬取与形态识别系统。该系统通过网络爬虫技术获取股票历史数据,使用Matplotlib生成K线图,并应用卷积神经网络(CNN)对经典K线形态进行识别。文章详细阐述了数据采集、K线图生成、CNN模型构建与训练的完整流程,并提供了完整的代码实现。本研究为金融科技领域的毕业设计提供了有价值的参考方案。关键词:Python爬虫、K线图、卷积神经网络、形态识别、股票交易。

2201_76125261的博客 1033

POJ2159 Ancient Cipher

POJ2159http://poj.org/problem?id=2159 题目大意:有点凯撒密码的意思,但是是向后移动一定的字符之后乱序排列形成密文。向后加密顺序相对好确定,但是还要错乱排序就显得很无解了。。。 思路:按照密码学的统计规律结合题意,既然是同时加密,只要求各字符出现的频率保持一致即可。 所以,我们只需统计两个字符串中字符出现的频率,进行对比即可。 AC代码...

Sensente的博客 282

解决Google Play签名问题:Android App Bundle上传指南

摘要:本文分享了解决Android App Bundle上传至Google Play时遇到的签名问题的经验。当使用pepk.jar工具加密私钥时,出现"NoSuchAlgorithmException"错误。解决方案包括:确保使用JDK 11+版本、更新pepk.jar工具、验证密钥库信息,并提供详细命令行示例。通过升级开发环境和正确配置签名参数,最终成功生成加密密钥文件。文章为开发者提供了实用的技术参考,强调耐心排查问题的重要性。(149字)

m0_62153576的博客 144

第02章:HSA-Runtime架构概览

摘要: 本章深入解析HSA Runtime的三层架构设计,包括公共API层(C语言接口)、核心实现层(C++业务逻辑)和驱动抽象层(硬件交互)。重点介绍了Runtime的核心组件(Agent、Queue、Signal、Memory)及其关系,以及初始化流程、配置选项和调试功能。通过学习,读者将掌握HSA Runtime的整体架构,为后续模块学习奠定基础。

图形/计算GPU的驱动与虚拟化技术分享园地 2925

poj 2159 : Ancient Cipher

依旧不会~~~~哎,菜呀~~

美文的ACM 456

【python股票价格预测】基于LSTM(长短期记忆网络)的股票价格预测(附python代码)

【python股票价格预测】基于LSTM(长短期记忆网络)的股票价格预测(附python代码)

k8291121的博客 1012

poj 2159Ancient Cipher

链接:http://poj.org/problem?id=2159

笙箫默 1105

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

POJ2159-Ancient Cipher

全解题报告索引目录 -> 【北大ACM – POJ试题分类】 转载请注明出处:http://exp-blog.com ------------------------------------------------------------------------- PS:本题稍微说一下题意(当时有点发牢骚的感觉,O(∩_∩)O哈哈~) 一种我认为是比较符合现实的解题思路,...

ζёСяêτ - 小優YoU 8934

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

Ancient Cipher POJ-2159 (排序)

Ancient Cipher POJ-2159 (排序) 传送门 思路:关键在于这句话: Substitution cipher changes all occurrences of each letter to some other letter. Substitutes for all letters must be different. For some letters substitute letter may coincide with the original letter. 意思就是每个字

Harris-H的博客 497

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

POJ2159Ancient Cipher

http://poj.org/problem?id=2159 做完了确实发现是水题一道。但是英文能力太渣,直接读错题意。大意了,以为只是给的例子的情况,直接写了窜一位的代码。果断各种WA,但是还不知道错在哪儿,也没回去再读题。一直以为是代码写错ORZ。还是应该WA了之后回去再看一遍题意,看看是不是直接读错了题意。 正确的题意是每个字母移动了多少位数固定切相互独立,那么只要在两个字符串里出现相同

写给自己的成长记录 600

【poj刷题记录】2159:Ancient Cipher

培养信心练手题,POJ2159题目描述如下: 这题乍一看挺简单,但我还是掉了一个坑ORZ。 解题思路其实就是求一下加密前和加密后的字符串是否等价,两种加密方法,第二种换位置法显然只是一个烟雾弹,只对排列顺序做改变,不对替换法之后的序列中字母本身(即涉及的字母有哪些以及每种字母有几个)做出改变。 我最一开始没有仔细读题,被举的例子误导,以为替换法是整体字符串统一加一个任意常数k,就把转换前后的两...

qq_38331950的博客 232

POJ 2159 Ancient Cipher Java题解

POJ 2159 Ancient Cipher Java题解

Exticntion的博客 375

POJ-2159 Ancient Cipher

其实这题也不算难,完全没必要用vector、map、pair来做这道题,但是我是想借此题练习一下相关用法。 此题的核心是:统计一个字符串中各个字母出现的频率。比如A出现两次,就记为频率为2 方法一我将用vector、map相关知识来解答 方法二我将用普通数组的方法来解答(26个大写字母减去 ‘A’ 得到的数字可以对应数组下标) 方法一: 知识点: map默认按照键的大小由小到大来排序,如果要按照...

sudo-wang的博客 303

poj 2159 Ancient Cipher

这题主要应该就是理解题意的问题,我的确是把题目理解错了,WA了三次,每次都以为一定是正确的,后来看了别人的解释才知道是题目理解错了(竟然还看到了别人的结题报告也有错的。。。) 开始错误的想法: #include #include #include #include using namespace std; int main() { char input[102],so

This is bill的专属博客 1566

Ancient Cipher POJ - 2159

题目链接 题目大意: 给2个字符串,求是否为经过加密的密码。 (后面是字符串是否为前面字符串的加密结果) 解题思路: 加密过程只有两种: 全部字符进行平移 将字符的位置进行替换 因此:只要判断字符的数量与之前的数量是否相符就行 (相符不要求相应的字母相同,而是要求个数相同就行) eg: 原本有A 2个,B 2 个, C 1个 加密后 D 2个 E 2个,F 1个。 (数量相对应) #inc...

LiangNiuMu的博客 203

Ancient Cipher POJ - 2159

题目:链接 思路分析:给两组字符串,对于第一组字符串,如果该字符串能通过某种置换以及排列成为第二个字符串,那么就可以称第二个字符串是第一个字符串的加密。 本题应该正确理解这里“变换”的定义:比如:A可以变为B(字母表的下一个),但是不一定会变为B,可以是任何字母,也可以不变,依然是它本身。所以,相同的字母变换后的字母也一定相同,位置或许会变,但频率不会变。因此两个字符串的频率一致是关键。 代码如...

fanxingxue的博客 201

POJ 2159 Ancient Cipher

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 th...

Logan 181
上一篇: POJ 3299 Humidex
下一篇: POJ 2739 Sum of Consecutive Prime Numbers
朔北冥
博客等级 码龄11年 14粉丝 27原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值