Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <string.h>
- #include <ctype.h>
- #pragma warning(disable:4996)
- typedef long long s64, LL;
- typedef unsigned long long u64, ULL;
- typedef const void *cvp;
- #define MAX(a,b) (((a)>(b))?(a):(b))
- int arr[6000010] = { 0 };
- int main(){
- #ifdef _DEBUG
- FILE *fp = freopen("../../../input.txt", "r", stdin);
- //FILE *fp2 = freopen("../../../output.txt", "w", stdout);
- #endif // _DEBUG
- int n, i, ans = 0, ans1;
- scanf("%d", &n);
- for(i = 0; i < n; i++){
- scanf("%d", arr + i);
- ans ^= arr[i];
- }
- if(n & 1){//奇数直接出答案
- printf("%d\n", ans);
- }
- else if(!ans){
- puts("False Alarm.");
- }
- else{
- ans1 = ans;
- int pos = 1, k;
- for(k = 0; k < 32; k++){
- if(ans1 & (1 << k)){
- pos = (1 << k); break;
- }
- }
- for(i = 0; i < n; i++){
- if(arr[i] & pos){
- ans ^= arr[i];
- }
- else{
- ans1 ^= arr[i];
- }
- }
- if(ans < ans1){
- printf("%d %d\n", ans, ans1);
- }
- else{
- printf("%d %d\n", ans1, ans);
- }
- }
- #ifdef _DEBUG
- fp = freopen("CON", "r", stdin);
- //fp2 = freopen("CON", "w", stdout);
- system("pause");
- #endif // _DEBUG
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment