博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
思维体操: HDU1287破译密码
阅读量:7027 次
发布时间:2019-06-28

本文共 1561 字,大约阅读时间需要 5 分钟。

破译密码

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5372    Accepted Submission(s): 2509
Problem Description
有个叫“猪头帮”的国家,采用一种简单的文法加密,他们所用的语言里面只有大写字母,没有其他任何字符;现在还知道他们加密的方法是:只用一个大写字母和原文进行异或运算生成密文。请你帮忙解开。
 
Input
有若干组,每组输入有2行,第一行整数N表示有N个密文,接着一行有N个整数分别表示N个密文。
 
Output
输出仅有大写字母组成的原文。
 
Sample Input
 
30 17 6 9 8 3 0 1 6 7 4 5 10 11 8 9 14 15 12 13 18 19 16 17 22 23 20 21 26 27 24
 
Sample Output
 
SDKJABCDEFGHIJKLMNOPQRSTUVWXYZ
 
Author
SmallBeer(CML)
 
Source
 
Problem :     Judge Status : Accepted
RunId : 21249667    Language : G++    Author :
Code Render Status : Rendered By HDOJ G++ Code Render Version 0.01 Beta
#include<iostream> #include<cstring> #include<cstdio> using namespace std; const int N = 1000 + 5; int a[N]; int main(){ int n,x,i; while(scanf("%d",&n)==1){ bool flag = 0; for(int i=0;i<n;i++) scanf("%d",&a[i]); for(x ='A';x <= 'Z';x++){ for(flag=1,i=0;i<n;i++){ if(((a[i]^x) >'Z')||((a[i]^x)<'A')){ flag = 0; break; } } if(flag) break; } for(int i=0;i<n;i++) printf("%c",a[i]^x); printf("\n"); } return 0 ; }
#include
#include
#include
using namespace std;const int N = 1000 + 5;int a[N];int main(){
int n,x,i; while(scanf("%d",&n)==1){
bool flag = 0; for(int i=0;i
'Z')||((a[i]^x)<'A')){
flag = 0; break; } } if(flag) break; } for(int i=0;i

转载于:https://www.cnblogs.com/Pretty9/p/7347712.html

你可能感兴趣的文章
MySQL查询性能优化---高性能(二)
查看>>
hadoop零基础系列之一:虚拟机下的Linux集群构建
查看>>
近 100 个 Linux 常用命令大全
查看>>
Bootstrap CSS
查看>>
Entity FrameWork 单表对多实体
查看>>
实验一框架的原因及说明
查看>>
第二次测试
查看>>
c语言编程之栈(链表实现)
查看>>
[leetcode-299-Bulls and Cows]
查看>>
python import
查看>>
hdu 1556 Color the ball
查看>>
第二次作业
查看>>
将用户输入的字符串反向输出到页面上,并且要求将其中的小写字母转换成大写字母。...
查看>>
somatic和germline突变有什么区别
查看>>
Android的TextView使用Html来处理图片显示、字体样式、超链接等
查看>>
python re的findall和finditer
查看>>
Feign 第一个Feign程序 一
查看>>
入门知识
查看>>
configparser 文件的生成和读写
查看>>
20个PHP程序性能优化的方法
查看>>