csuoj 1396: Erase Securely

http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1396

1396: Erase Securely

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 102  Solved: 60
[Submit][Status][Web Board]

Description

Input

Output

Sample Input

1
10001110101000001111010100001110
01110001010111110000101011110001

Sample Output

Deletion succeeded

HINT

分析;

异或。

AC代码:

 1 #include <stdio.h>
 2 #include <string.h>
 3 #include <algorithm>
 4 
 5 using namespace std;
 6 
 7 const int N = 1e3 + 5;
 8 
 9 char a[N],b[N];
10 
11 int main()
12 {
13     int n;
14     while(~scanf("%d",&n))
15     {
16         scanf("%s%s",a,b);
17         int len = strlen(a);
18         n = n & 1;
19         bool ok = true;
20         for(int i=0;i<len;i++)
21             if((a[i] ^ n) != b[i])
22             {
23                 ok = false;
24                 break;
25             }
26         puts(ok ? "Deletion succeeded" : "Deletion failed");
27     }
28     return 0;
29 }
原文地址:https://www.cnblogs.com/jeff-wgc/p/4474857.html