Hust oj 1341 Who will be punished(字符串异或)

Who will be punished
Time Limit: 1000 MSMemory Limit: 32767 K
Total Submit: 563(95 users)Total Accepted: 210(82 users)Rating: Special Judge: No
Description

This time,suddenly,teacher Li wants to find out who have missed interesting DP lesson to have fun.The students who are found out will get strictly punishment.Because,teacher Li wants all the students master the DP algorithm.

However,Li doesn't want to waste the class time to call over the names of students.So he let the students to write down their names in one paper.To his satisfaction,this time, only one student has not come.

He can get the name who has not come to class,but,it is troublesome,and,teacher always have many things to think about,so,teacher Li wants you, who is in the ACM team, to pick out the name.

Input

There are several test cases.The first line of each case have one positive integer N.N is the  number of the students,and N will not greater than 500,000.

Then,following N lines,each line contains one name of students who have attended class.The N-1 lines are presented after N lines.These N-1 lines indicates the names of students who have come to class this time,one name in one line.

The length of student's name is not greater than 30.

Process to the end of file.

Output
For each test case, first print a line saying "Scenario #k", where k is the number of the test case.Then output the name of the student who have not come to class.One case per line.Print a blank line after each test case, even after the last one.
Sample Input

3

A

B

C

B

C

Sample Output

Scenario #1

A

异或性质,A^B^A=B,对字符串同样适用

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;

int n;
char a[50];
char start[50];

int main()
{
    int cnt = 0;
    while(~scanf("%d",&n))
    {
        getchar();
        scanf("%s",&start);
        for(int i=0;i<2*n-2;i++)
        {
            scanf("%s",&a);
            int len = strlen(a);
            for(int j=0;j<len;j++)
            {
                start[j] ^= a[j];
            }
        }
        printf("Scenario #%d\n",++cnt);
        printf("%s\n\n",start);
    }
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值