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. JAVA 获取类名,函数名

    获取以下获取方法所在函数的相关信息 1.获取当前函数名:Thread.currentThread().getStackTrace()[1].getMethodName(); 2.获取当前类名:Thre ...

  2. 关系型数据库(四),引擎MyISAM和InnoDB

    目录 1.MyISAM和InnoDB关于锁方面的区别是什么 2.MYSQL的两个常用存储引擎 3.MyISAM应用场景 4.InnoDB适合场景 四.引擎MyISAM和InnoDB 1.MyISAM和 ...

  3. 【GDSOI2019】滑稽二乘法【数据结构】【LCT】

    Description 点数<=100000,操作数<=200000 Solution 经典的LCT维护子树路径信息的问题. 具体来说,我们对于每一个节点,它在splay上的子树对应了原树 ...

  4. 【杂题】[AGC034F] RNG and XOR【集合幂级数】【FWT】【DP】

    Description 你有一个随机数生成器,它会以一定的概率生成[0,2^N-1]中的数,每一个数的概率是由序列A给定的,Pi=Ai/sum(Ai) 现在有一个初始为0的数X,每一轮随机生成一个数v ...

  5. Hnoi2017试题泛做

    Day1 4825: [Hnoi2017]单旋 注意到二叉查找树的一个性质:其中序遍历就是所有元素按权值排序的顺序. 所以我们可以离线地把这棵树的中序遍历求出来.然后我们在插入的时候就可以用一个set ...

  6. matplotlib绘图时显示额外的“figure”浮窗

    引自 https://blog.csdn.net/weixin_41571493/article/details/82690052 问题:现在默认的Pycharm绘图时,都会出现下面的情况: 不能弹出 ...

  7. Python实用黑科技——找出最大/最小的n个元素

    需求: 快速的获取一个列表中最大/最小的n个元素. 方法: 最简便的方法是使用heapq模组的两个方法nlargest()和nsmallest(),例如: In [1]: import heapqIn ...

  8. ID生成 雪花算法

    /** * ID生成 雪花算法 */ public class SnowFlake { public static SnowFlake getInstance() { return Singleton ...

  9. python虚环境

    有的项目使用tornado框架比较好,有的用Django框架比较好,容易发生冲突,这个时候可以建立一个虚拟的python环境. 安装virtualenv包 进入项目所在目录,执行命令 virtuale ...

  10. java 后台封装json数据学习总结

    一.数据封装 1. List集合转换成json代码 List list = new ArrayList(); list.add( "first" ); list.add( &quo ...