HDU1287+枚举
为什么不会有多个答案。。。求解释。。。
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 /* 2 异或运算 3 a^b^b = a; 4 1. a ^ b = b ^ a 5 2. a ^ b ^ c = a ^ (b ^ c) = (a ^ b) ^ c; 6 3. d = a ^ b ^ c 可以推出 a = d ^ b ^ c. 7 4. a ^ b ^ a = b 8 9 枚举res的时候,为什么不可能出现多个满足题意的答案? 10 11 */ 12 #include<stdio.h> 13 #include<string.h> 14 #include<stdlib.h> 15 #include<algorithm> 16 #include<iostream> 17 #include<queue> 18 #include<vector> 19 #include<map> 20 #include<math.h> 21 typedef long long ll; 22 //typedef __int64 int64; 23 const int maxn = 10005; 24 const int maxm = 1005; 25 const int inf = 0x7FFFFFFF; 26 const double pi = acos(-1.0); 27 const double eps = 1e-8; 28 using namespace std; 29 int a[ maxn ]; 30 int main(){ 31 int n; 32 while( scanf("%d",&n)!=EOF ){ 33 for( int i=0;i<n;i++ ) 34 scanf("%d",&a[i]); 35 int res ; 36 for( int i=0;i<26;i++ ){ 37 int j; 38 for( j=0;j<n;j++ ){ 39 if( (a[j]^(i+'A'))>='A'&&(a[j]^(i+'A'))<='Z' ){} 40 else break; 41 } 42 if( j>=n ){ 43 res = i; 44 break; 45 } 46 } 47 for( int i=0;i<n;i++ ){ 48 printf("%c",((res+'A')^a[i])); 49 } 50 printf("\n"); 51 } 52 return 0; 53 }
keep moving...