2015百度之星资格赛1002列变位法解密

裂变位法加密 best coder 列变位法解密 Accepts: 75 Submissions: 206 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Description 列变位法是古典密码算法中变位加密的一种方法,具体过程如下将明文字符分割成个 阅读详情
一遍就AC了,时间来不及了,就做一道吧
Problem Description

列变位法是古典密码算法中变位加密的一种方法,具体过程如下将明文字符分割成个数固定的分组(如5个一组,5即为密钥),按一组一行的次序整齐排列,最后不足一组不放置任何字符,完成后按列读取即成密文。

比如:

原文:123456789

密钥:4

变换后的矩阵:

1234
5678
9xxx

(最后的几个x表示无任何字符,不是空格,不是制表符,就没有任何字符,下同)

密文:159263748

再比如:

原文:Hello, welcome to my dream world!

密钥:7

变换后的矩阵:

Hello,
welcome
 to my 
dream w
orld!xx

密文:

Hw doeetrrlloellc adoomm!,my e w

实现一个利用列变位法的加密器对Bob来说轻而易举,可是,对Bob来说,想清楚如何写一个相应的解密器似乎有点困难,你能帮帮他吗?

Input

第一行一个整数T,表示T组数据。

每组数据包含2行

第一行,一个字符串s(1≤|s|≤1e5),表示经过列变位法加密后的密文

第二行,一个整数K(1≤K≤|s|),表示原文在使用列变位法加密时的密钥

输入保证密文字符串中只含有ASCII码在[0x20,0x7F)范围内的字符

Output

对于每组数据,先输出一行

Case #i:

然后输出一行,包含一个字符串s_decrypt,表示解密后得到的明文

Sample Input
4
159263748
4
Hw doeetrrlloellc adoomm!,my  e w
7
Toodming is best
16
sokaisan
1
Sample Output
Case #1:
123456789
Case #2:
Hello, welcome to my dream world!
Case #3:
Toodming is best
Case #4:
sokaisan


#include<stdio.h>
#include<string.h>
char a[100002]={0},b[100001]={0};
int main()
{
	int n,i,sum,lenth,hang,lie,yu,j,k;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		sum=0;
		getchar();
		gets(a);
		lenth=strlen(a);
		scanf("%d",&lie);
		hang=lenth/lie;
		yu=lenth%lie;
		for(k=0;k<lie;k++)
		{
			if(k<yu)
			{
				for(j=0;j<=hang;j++)
				{
				
					b[k+j*lie]=a[sum];
					sum++;
				}
			}
			else
			{
				for(j=0;j<hang;j++)
				{
				
					b[k+j*lie]=a[sum];
					sum++;
				}
			}
		}
		printf("Case #%d:\n",i+1);
		puts(b);
		for(j=0;j<lenth;j++)
		{
			a[j]=b[j]=0;
		}
	}
	return 0;
}


ROS2节点通信实战:用C++手写一个‘智能小车’控制模型(附完整代码) 本文详细介绍了如何使用ROS2和C++构建一个智能小车控制模型,涵盖运动控制节点、电池管理服务、参数动态配置和Rviz可视化等核心功能。通过实战项目演示ROS2节点通信机制,帮助开发者快速掌握机器人开发的关键技术,并提供了完整的代码实现和系统集成方案。 阅读详情

相关推荐

codemirror6 制作markdown编辑器(源码模式)

总体上感觉能用,但是不怎么友好,官方文档有点散乱,而且关键字高亮功能是独立出去的,去官方文档找半天,也没找到怎么改。EditorView.theme可以往EditorView模块中修改CSS的样式,从而影响编辑器的样式展示。"### 测试\n\n```javascript\nlet x = 'y'\n```"这个插件中的markdown语法的高亮样式。//这里指定markdown中代码块使用的解析扩展。开头的class样式,并且还需要在选择器前面添加。//markdown语言解析扩展。

qq_43203949的博客 1783

密码学——常见的密码学习总结

1 基本概念(*) 密码学又分为密码编码学(Cryptography)和密码分析学(Cryptanalysis)。 在密码学中,一个密码体制或密码系统是指由明文、密文、密钥、加密算法和解密算法所组成的五元组。 明文是指未经过任何变换处理的原始消息,通常用m(message)或p( plaintext)表示。所有可能的明文有限集组成明文空间,通常用M或P表示。 密文是指明文加密后的消息,通常...

xlsj雪松的博客 1万+

相机图像质量研究(22)常见问题总结:CMOS期间对成像的影响--光学串扰

光学串扰是一个比较难以理解的光学现象,实际影响往往不大。一、光学串扰产生的原因通常是入射角度太大,光线在不同通道之间产生了混叠二、光学串扰产生的现象光学串扰容易导致迷宫纹。总结本节讲了光学串扰产生的原因,现象。

xiaoshixiu的专栏 1573

常用加密算法概述

题外话:最近某人在参加CTF比赛,为了寻找共同话题,并督促很久没动过脑的我学习,也给我讲解了几道题。经过考虑,加密方面的题和我的专业相符些,所以决定先攻破这方面的一些习题,权作打发时间了。在此总结一些作题过程中涉及的算法,加深记忆。 1.base64 概述:把明文对应成64个字符的加密算法。 方法:每个字符对应8位二进制数,因此可把字符转化为二进制数。将每6个二进制数作为一个单位,那么共有64个这样的6位二进制数。设定64个字符与上述二进制数一一对应。如此,在对字符加密时,可先将字符转化为二进制数,再将

LucyGill的博客 773

SAR成像系列:【3】合成孔径雷达(SAR)的二维回波信号与简单距离多普勒(RD)算法 (附matlab代码)

二维回波信号分析

zr2006_7的专栏 2万+

5分钟搞定Vivado IP核的VCS仿真:从Export脚本到Verdi波形查看全流程

本文详细介绍了如何利用Vivado的Export Simulation功能,快速搭建Vivado IP核的VCS与Verdi联合仿真环境。通过自动化脚本生成、FSDB波形配置及高效调试技巧,实现从工程导出到波形查看的全流程,大幅提升FPGA验证效率,尤其适合IC验证工程师和竞赛团队。

weixin_29306261的博客 478

解密

T5解密 时间限制:1000ms 【问题描述】 列变位法是古典密码算法中变位加密的一种方法,具体过程如下:将明文字符分割成个数固定的分组(如5个一组,5即为密钥),按一组一行的次序整齐排列,最后不足一组不放置任何字符,完成后按列读取即成密文。 比如: 原文:123456789 密钥:4 变换后的矩阵: 1234 5678 9xxx (最后的几个x表示无任何字符,不是空格,不是制

大肉包的博客 691

AD18软件——捕捉栅格、电气栅格、可见栅格的意义及设置

本文介绍了PCB设计中的三种栅格功能:可视栅格用于辅助定位(快捷键Shift+Ctrl+G),捕捉栅格控制光标移动间距(快捷键G),电气栅格实现元件自动吸附(快捷键Shift+E)。同时提供了在Altium Designer中快速查找相同网络标号的两种实用方法:Alt+鼠标单击或双击网络。这些功能可显著提高PCB设计效率和准确性。

qq_37999850的博客 643

列变位法解密

列变位法是古典密码算法中变位加密的一种方法,具体过程如下 将明文字符分割成个数固定的分组(如5个一组,5即为密钥),按一组一行的次序整齐排列,最后不足一组不放置任何字符,完成后按列读取即成密文。 比如: 原文:123456789 密钥:4 变换后的矩阵: 1234 5678 9xxx (最后的几个x表示无任何字符,不是空格,不是制表符,就没有任何

Collider 2852

基于STM32L4XX、HAL库的DP83822 以太网收发器(PHY)驱动程序设计

一、简介:DP83822是德州仪器(TI)推出的一款低功耗、高性能10/100Mbps以太网物理层收发器(PHY)。它具有以下主要特性:支持10BASE-T和100BASE-TX以太网标准低功耗设计,适合嵌入式应用MII/RMII接口,方便与微控制器连接内置自检和诊断功能支持自动协商和手动配置工业级温度范围(-40°C至+85°C)

zhusl6688的博客 525

ABAP Development Tool for Visual Studio Code 里使用 MCP server

本文讨论了SAP ABAP开发环境中,除GitHub Copilot外,其他可作为MCP客户端接入ABAP开发工具(MCP server)的编码代理(coding agent)。GitHub Copilot是官方确认可用的工具,而其他代理如Claude Code、Cursor、Windsurf Cascade、Cline和Continue虽然理论上支持MCP协议,但要实际用于ABAP开发还需满足两个关键条件:兼容MCP协议,并能处理VS Code虚拟工作区文件系统。这些工具需要单独验证是否支持ABAP开发工

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 255

2015百度之星资格赛 列变位法解密 1002

列变位法解密 Accepts: 1644 Submissions: 6646 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Description 列变位法是古典密码算法中变位加密的一种方法,具体过程如下将明文字符分割成

豫帝哥哥 1018

28、基准剂量法:原理、应用与计算详解

本文详细介绍了基准剂量法(BMD)的原理、在监管机构中的应用以及具体的计算方法。内容涵盖样本量与BMD的关系、主要监管机构如EPA对BMD的应用、BMD的模型选择与数据拟合过程、拟合优度评估、下置信限(BMDL)计算,以及实验设计对BMD结果的影响。同时,还讨论了剂量指标和响应选择的关键问题,为理解和应用基准剂量法提供了全面的参考。

info6的博客 280

bestCoder 2015 百度之星程序设计大赛 资格赛-1002-列变位法解密

列变位法解密 Accepts: 1342 Submissions: 5184 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Description 列变位法是古典密码算法中变位加密的一种方法,具体过程如下将明文字符分割成

qq_18661257的专栏 851

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

字符串处理 2015百度之星资格赛 1002 列变位法解密

题目传送门 1 /* 2 字符串处理:要求解码,然而二维数组开不下,可以直接输出 3 只要在余数的地方判断一下就行了,vector的效率不高 4 另外:感觉麻烦的地方应该纸上写写就清楚了 5 */ 6 #include <cstdio> 7 #include <iostream> 8 #includ...

weixin_30753873的博客 118

深度学习工具包 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")

2015百度之星资格赛1002_列变位法解密

题目链接:http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=584&pid=1002这题好麻烦啊,wa了好几次,开始的时候以为思路错了,换用一维数组存储矩阵去做,结果超时了,后来一想是忽略了正常的没有空的情况 ⊙▂⊙ ,加上之后就AC了。。。 #include<stdio.h> #include<string.h> #

希望更好 787

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

2015年百度之星程序设计大赛——资格赛(1002列变位法解密)

Problem Description 列变位法是古典密码算法中变位加密的一种方法,具体过程如下 将明文字符分割成个数固定的分组(如5个一组,5即为密钥),按一组一行的次序整齐排列,最后不足一组不放置任何字符,完成后按列读取即成密文。比如:原文:123456789密钥:4变换后的矩阵:1234 5678 9xxx (最后的几个x表示无任何字符,不是空格,不是制表符,就没有任何字符,下同)密文

2cm的专栏 617

2015年百度之星程序设计大赛 - 资格赛:1002列变位法解密

列变位法解密  Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description 列变位法是古典密码算法中变位加密的一种方法,具体过程如下 将明文字符分割成个数固定的分组(如5个一组,5即为密钥),按一组一行的次序整齐排

Han_kin的专栏 887

ACM学习历程—BestCoder 2015百度之星资格赛1002 列变位法解密(vector容器)

Problem Description 列变位法是古典密码算法中变位加密的一种方法,具体过程如下 将明文字符分割成个数固定的分组(如5个一组,5即为密钥),按一组一行的次序整齐排列,最后不足一组不放置任何字符,完成后按列读取即成密文。 比如: 原文:123456789 密钥:4 变换后的矩阵: 1234 5678 9xxx (最后的几个x表示无任何字符,不是空格,不是制...

weixin_30299539的博客 125

百度之星2015资格赛#1002

列变位法解密 Accepts: 1233 Submissions: 4720  Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Problem Description 列变位法是古典密码算法中变位加密的一种方法,具体过程如下 将明文字符分割成个数固定的分组(如5个一组,5即为密钥

无比芜杂的代码 916

2015百度之星资格赛1002

题目名称:列变位法解密  题目链接:http://bestcoder.hdu.edu.cn/contests/contest_showproblem.php?cid=584&pid=1002 Problem Description 列变位法是古典密码算法中变位加密的一种方法,具体过程如下 将明文字符分割成个数固定的分组(如5个一组,5即为密钥),按一组一行的次序整齐排列,最后

ACMer中的渣渣 607

2015百度之星资格赛解题报告

1001 大搬家    Accepts: 1516    Submissions: 6288  Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Problem Description 近期B厂组织了一次大搬家,所有人都要按照指示换到指

ACway的专栏 2735
上一篇: HDU3791
下一篇: 迷宫问题
seekforcode
博客等级 码龄12年 9粉丝 41原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值