Who will be punished

Problem 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

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.

Output

output the name of the student who have not come to class.

Sample Input

3
A
B
C
B
C

Sample Output

A

解释:

找到只出现过一次的人的名字,而其他人都出现了两次。那么用一个字符串去异或,异或。毕竟东一个名字的,出现两次,那么两次的相同位置的字符肯定是一样。

 #include<stdio.h>
#include<string.h>
int main()
{
void fun(int n);
int n;
while(scanf("%d",&n)!=EOF)
fun (n);
return ;
}
void fun (int n)
{ int j,i,a;
char str1[],str2[];
n=n*;
for(i=;i<;i++)
str2[i]=;
for(i=;i<n;i++)
{
gets(str1);
a=strlen(str1);
for(j=;j<a;j++)
str2[j]=str1[j]^str2[j];
}
puts(str2);
}

Who will be punished的更多相关文章

  1. Bestcoder#5 1002

    Bestcoder#5 1002 Poor MitsuiTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (J ...

  2. An Unfair Game-[ACdream1035]

    Problem Description There are n people and n target, everyone should get one target, no two people g ...

  3. 2016年12月26日 星期一 --出埃及记 Exodus 21:21

    2016年12月26日 星期一 --出埃及记 Exodus 21:21 but he is not to be punished if the slave gets up after a day or ...

  4. 2016年12月25日 星期日 --出埃及记 Exodus 21:20

    2016年12月25日 星期日 --出埃及记 Exodus 21:20 "If a man beats his male or female slave with a rod and the ...

  5. [ACM_水题] Yet Another Story of Rock-paper-scissors [超水 剪刀石头布]

    Description Akihisa and Hideyoshi were lovers. They were sentenced to death by the FFF Inquisition. ...

  6. AngularJS Providers 详解

    供应者(Providers) Each web application you build is composed of objects that collaborate to get stuff d ...

  7. spotify engineering culture part 1

    原文 ,因为原视频说的太快太长, 又没有字幕,于是借助youtube,把原文听&打出来了. 中文版日后有时间再翻译. one of the big succeess factors here ...

  8. HDU4887_Endless Punishment_BSGS+矩阵快速幂+哈希表

    2014多校第一题,当时几百个人交没人过,我也暴力交了几发,果然不行. 比完了去学习了BSGS才懂! 题目:http://acm.hdu.edu.cn/showproblem.php?pid=4887 ...

  9. zjuoj 3610 Yet Another Story of Rock-paper-scissors

    http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3610 Yet Another Story of Rock-paper-sc ...

随机推荐

  1. 计算机网络(四),TCP三次握手

    目录 1.三次握手详情 2.为什么需要三次握手才能建立连接 3.首次握手的隐患---SYN超时的问题 4.建立连接之后,Client出现故障 四.TCP三次握手 1.三次握手详情 (1)一开始,客户端 ...

  2. Remove the Substring

    D2. Remove the Substring (hard version) 思路:其实就是贪心吧,先从前往后找,找到 t 可在 s 中存在的最小位置 (pre),再从后往前找,找到 t 可在 s ...

  3. PHP 判断当前日期是否是法定节假日或者休息日 (原)

    //判断日期是不是节假日或者双休日接口 @param time [时间(时间戳或者Y-m-d都可)] public function get_type_by_date(){ $t = $_GET['t ...

  4. JavaWeb_通过xml配置文件配置servlet访问路径

    Servlet两种访问路径 一.在Servlet类中通过设置@WebServlet标注访问 二.在web.xml中编写配置文件 第一种能比较直观看到Servlet路径,但当项目发布后不好再对Servl ...

  5. shell定义

    用户输入的命令并且把它们送到内核.不仅如此,Shell有自己的编程语言用于对命令的编辑,它允许用户编写由shell命令组成的程序. Shell编程语言具有普通编程语言的很多特点 无图形化界面时与lin ...

  6. 【学习】windows 下PostgreSQL导入sql文件

    在软件的安装目录的bin文件下打开命令行工具 输入: psql -d 数据库名称 -h 数据库地址 -p  5432  -U  postgres  -f  sql文件(E:\Config\SQL\iS ...

  7. webpack学习之路--demo1

    1.不使用框架建立webpack项目时 (1).npm init -y 生成package.json文件 (2).npm install --save-dev webpack 在当前项目下安装webp ...

  8. js中filter过滤用法总结

    定义和用法 filter() 方法创建一个新的数组,新数组中的元素是通过检查指定数组中符合条件的所有元素. 注意: filter() 不会对空数组进行检测. 注意: filter() 不会改变原始数组 ...

  9. LeetCode 22. 括号生成(Generate Parentheses)

    题目描述 给出 n 代表生成括号的对数,请你写出一个函数,使其能够生成所有可能的并且有效的括号组合. 例如,给出 n =3,生成结果为: [ "((()))", "(() ...

  10. ubuntu下mysql数据库存储路径修改

    一.安装mysql ubuntu系统安装配置APT源,apt install mysql-server mysql-client 二.查看安装端口情况 sudo netstat -tap | grep ...