:::---> a = b ^ c —-> c = a ^ b b = a ^ c,就是异或递推的关系。
http://acm.hdu.edu.cn/showproblem.php?pid=1287
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
//
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 ;
}
#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 ;
}