hdu1287

:::--->    a = b ^ c —-> c = a ^ b b = a ^ c,就是异或递推的关系。

http://acm.hdu.edu.cn/showproblem.php?pid=1287

View Code
// a = b ^ c —-> c = a ^ b b = a ^ c
#include"iostream"
#include
"math.h"
using namespace std;
int main()
{
int n,i;
int a[1000];
char ch;

while(cin>>n)
{
for(i=0;i<n;i++)
scanf(
"%d",&a[i]);

int count=0;
char xx;
for(ch='A'; ch<='Z'; ++ch)
{
count
=0;
for(i=0; i<n; i++)
{
xx
=a[i]^ch;
if(xx<='Z'&& xx>='A') count++;
}
if(count==n) break;

}

for(i=0;i<n;i++)
{
printf(
"%c",a[i]^ch);
}
printf(
"\n");
}

return 0;
}
posted @ 2011-04-02 19:45  聊聊IT那些事  阅读(219)  评论(0编辑  收藏  举报