POJ 2159(古代加密) 解题报告

本文介绍了一个关于古罗马加密技术的问题——POJ2159题“Ancient Cipher”的解决方法。该题涉及替换加密和排列加密两种方式,并通过统计字母频率来验证加密过程的有效性。

  /*_____________________________________POJ 2159题____________________________________________ Ancient Cipher Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 4701 Accepted: 1905 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 popular ciphers in those times were so called substitution cipher and permutation cipher. 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. For example, applying substitution cipher that changes all letters from 'A' to 'Y' to the next ones in 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. For example, applying the permutation <2, 1, 5, 4, 3, 7, 6, 10, 9, 8> to the message "VICTORIOUS" one gets the message "IVOTCIRSUO". It was quickly noticed that being applied separately, both substitution cipher and permutation cipher were rather weak. But when being combined, they were strong enough for those times. Thus, the most important messages were first encrypted using substitution cipher, and then the result was encrypted using permutation cipher. Encrypting the message "VICTORIOUS" with the combination of the ciphers described above one gets the message "JWPUDJSTVP". Archeologists have recently found the message engraved on a stone plate. At the first glance it seemed completely meaningless, so it was suggested that the message was encrypted with some substitution and permutation ciphers. They have conjectured the possible text of the original message that was encrypted, and now they want to check their conjecture. They need a computer program to do it, so you have to write one. Input: Input contains two lines. The first line contains the message engraved on the plate. Before encrypting, all spaces and punctuation marks were removed, so the encrypted message contains only capital letters of the English alphabet. The second line contains the original message that is conjectured to be encrypted in the message on the first line. It also contains only capital letters of the English alphabet. 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 the result of encrypting the message on the second line, or "NO" in the other case. Sample Input: JWPUDJSTVP VICTORIOUS Sample Output: YES ____________________________________________________________________________________________*/ #include<stdio.h> #include<string.h> void Sort(int p[],int n) //冒泡排序,从大到小 { int temp; int flag=0; for(int i=1; i<n; i++) { flag=0; for(int j=0; j<n-i; j++) if(p[j]<p[j+1]) { flag=1; temp=p[j]; p[j]=p[j+1]; p[j+1]=temp; } if(flag==0) break; } } int main() { int i; char encrypted[110]={'/0'}; //密文 char supposed[110]={'/0'}; //猜想的明文 int e_count[26]={0}; //统计密文中每个字符的出现次数 int s_count[26]={0}; //统计猜想的明文中每个字符的出现次数 // FILE *fin=fopen("input.txt","r"); // fscanf(fin,"%s",encrypted); // fscanf(fin,"%s",supposed); scanf("%s",encrypted); scanf("%s",supposed); for(i=0; i<strlen(supposed); i++) { s_count[supposed[i]-'A']++; //s_count[0]存放supposed[]中A的出现次数,以此类推 e_count[encrypted[i]-'A']++; //e_count[0]存放encrypted[]中A的出现次数,以此类推 } Sort(s_count,26); //从大到小排序 Sort(e_count,26); /* for(i=0;i<26;i++) printf("%d ",s_count[i]); printf("/n"); for(i=0;i<26;i++) printf("%d ",e_count[i]); printf("/n"); */ for(i=0; i<26 && e_count[i]==s_count[i]; i++); //比较e_count[]和s_count[]是否完全相同 if(i==26) printf("YES"); else printf("NO"); return 0; } //原来我以为“替换”只能是在26个大写英文字母之间平移,后来发现“替换”可以是字母之间的任意映射, //所以只要统计明文和密文中各字母的出现次数,若出现次数序列完全相同,则此明文可加密为此密文

转载于:https://www.cnblogs.com/javaexam2/archive/2011/03/15/2632986.html

标题基于SpringBoot的马术俱乐部管理系统设计与实现AI更换标题第1章引言介绍马术俱乐部管理系统的研究背景、意义、国内外研究现状、论文方法及创新点。1.1研究背景与意义阐述马术俱乐部管理系统对提升俱乐部管理效率的重要性。1.2国内外研究现状分析国内外马术俱乐部管理系统的发展现状及存在的问题。1.3研究方法以及创新点概述本文采用的研究方法,包括SpringBoot框架的应用,以及系统的创新点。第2章相关理论总结和评述与马术俱乐部管理系统相关的现有理论。2.1SpringBoot框架理论介绍SpringBoot框架的基本原理、特点及其在Web开发中的应用。2.2数据库设计理论阐述数据库设计的基本原则、方法以及在管理系统中的应用。2.3马术俱乐部管理理论概述马术俱乐部管理的基本理论,包括会员管理、课程安排等。第3章系统设计详细描述马术俱乐部管理系统的设计方案,包括架构设计、功能模块设计等。3.1系统架构设计给出系统的整体架构,包括前端、后端和数据库的交互方式。3.2功能模块设计详细介绍系统的各个功能模块,如会员管理、课程管理、预约管理等。3.3数据库设计阐述数据库的设计方案,包括表结构、字段设计以及数据关系。第4章系统实现介绍马术俱乐部管理系统的实现过程,包括开发环境、编码实现等。4.1开发环境搭建介绍系统开发所需的环境,包括操作系统、开发工具等。4.2编码实现详细介绍系统各个功能模块的编码实现过程。4.3系统测试与调试阐述系统的测试方法、测试用例以及调试过程。第5章系统应用与分析呈现马术俱乐部管理系统的应用效果,并进行性能分析。5.1系统应用情况介绍系统在马术俱乐部中的实际应用情况。5.2系统性能分析从响应时间、并发处理能力等方面对系统性能进行分析。5.3用户反馈与改进收集用户反馈,提出系统改进建议。第6章结论与展望总结马术俱乐部管理系统的设计与实现成果,并展望未来的研究
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值