最开始以为这道题说的加密字母一直是同一个,看了Discuss才知道原来每次用的都可能不一样。因此枚举26个字母就行了,但是要求以后之后的值是大写字母的ASCII的值。感觉这道题出的有问题,如果同时有多个字母满足的了条件会怎么样判断?
题目URL:http://acm.hdu.edu.cn/showproblem.php?pid=1287
#include<iostream>
#include<stdio.h>
using namespace std;
const int Max = 2000;
int d[Max];
char str[Max];
int main()
{
int n;
while(scanf("%d", &n) != EOF)
{
for(int i=0; i<n; i++) scanf("%d", d+i);
char c;
for(c='A'; c<='Z'; c++)
{
int j=0;
for(; j<n; j++)
{
int t = d[j] ^ c;
if(!(t>='A' && t<= 'Z')) break;
}
if(j == n) break;
}
for(int i=0; i<n; i++) printf("%c", d[i] ^ c);
printf("\n");
}
system("pause");
return 0;
}