ZOJ 3432 Find the Lost Sock (异或的运用)
Alice bought a lot of pairs of socks yesterday. But when she went home, she found that she has lost one of them. Each sock has a name which contains exactly 7 charaters.
Alice wants to know which sock she has lost. Maybe you can help her.
Input
There are multiple cases. The first line containing an integer n (1 <= n <= 1000000) indicates that Alice bought n pairs of socks. For the following 2*n-1 lines, each line is a string with 7 charaters indicating the name of the socks that Alice took back.
Output
The name of the lost sock.
Sample Input
2
aabcdef
bzyxwvu
bzyxwvu
4
aqwerty
eas fgh
aqwerty
easdfgh
easdfgh
aqwerty
aqwerty
2
0x0abcd
0ABCDEF
0x0abcd
Sample Output
aabcdef
eas fgh
0ABCDEF
题意:
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<memory.h>
using namespace std;
char s[],c;
int main()
{
int n;
while(~scanf("%d\n",&n)){
for(int i=;i<=;i++) s[i]='\0';
for(int i=;i<*n;i++){
for(int j=;j<;j++){
c=getchar();
s[j]=s[j]^c;
}
}
printf("%s",s);
}
return ;
}
ZOJ 3432 Find the Lost Sock (异或的运用)的更多相关文章
- 【整理】XOR:从陌生到头晕
一:解决XOR常用的方法: 在vjudge上面输入关键词xor,然后按照顺序刷了一些题. 然后大概悟出了一些的的套路: 常用的有贪心,主要是利用二进制的一些性质,即贪心最大值的尽量高位取1. 然后有前 ...
- (二进制 异或)Team Formation --ZOJ --3870
链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3870 http://acm.hust.edu.cn/vjudge/ ...
- 【TOJ 3812】Find the Lost Sock(异或)
描述 Alice bought a lot of pairs of socks yesterday. But when she went home, she found that she has lo ...
- ZOJ - 3870 Team Formation(异或)
题意:给定N个数,求这N个数中满足A ⊕ B > max{A, B})的AB有多少对.(A,B是N中的某两个数) 分析: 1.异或,首先想到转化为二进制. eg:110011(A)和 1(B)- ...
- 位运算 ZOJ 3870 Team Formation
题目传送门 /* 题意:找出符合 A^B > max (A, B) 的组数: 位运算:异或的性质,1^1=0, 1^0=1, 0^1=1, 0^0=0:与的性质:1^1=1, 1^0=0, 0^ ...
- 【转载】图论 500题——主要为hdu/poj/zoj
转自——http://blog.csdn.net/qwe20060514/article/details/8112550 =============================以下是最小生成树+并 ...
- ZOJ 3529 A Game Between Alice and Bob(博弈论-sg函数)
ZOJ 3529 - A Game Between Alice and Bob Time Limit:5000MS Memory Limit:262144KB 64bit IO For ...
- zimbra6同域名与同hostname与同系统异机恢复
系统:redhat5.4_64 安装DNS:[root@test6 ~]# yum install bind -y[root@test6 ~]# yum install bind-chroot -y[ ...
- ZOJ Problem Set - 3593 拓展欧几里得 数学
ZOJ Problem Set - 3593 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3593 One Person ...
随机推荐
- [ios]ios语音识别
参考:http://blog.sina.com.cn/s/blog_923fdd9b0101flx1.html 通过谷歌语音接口的实现语音识别 最近在项目中有需要实现语音识别的功能.折腾了几天才搞好. ...
- 小橙书阅读指南(十三)——连通性算法(union-find)
上一章我大概说明了什么是图论以及无向图的基础概念,本章我们要研究一种更普遍的算法——连通性算法.它属于图论的分支,也是一种抽象算法.在深入算法之前,我们先提出一个具体的问题:假设在空间中存在N个点,我 ...
- Codeforces 847H - Load Testing
847H - Load Testing 思路:dp. 代码: #include<bits/stdc++.h> using namespace std; #define ll long lo ...
- 为arm 编译包含gd的php5
1) 下载gd的各种依赖包. 但是不要下载gd本身,因为这是包含在php里的. 探索的时候也下载了 libvpx freetype,可惜最后的编译没过,就没有用上 2)编译各种(编译前记得把各种环境变 ...
- English trip -- MC(情景课)3 D
xu言: have a nice weekend... sentences How many people are there in you family? they are 3 people in ...
- ps命令各个内容信息详解
USER 用户名 PID 进程ID(Process ID) %CPU 进程的cpu占用率 %MEM 进程的内存占用率 VSZ 进程所使用的虚存的大小(Vi ...
- Johnny Solving CodeForces - 1103C (构造,图论)
大意: 无向图, 无重边自环, 每个点度数>=3, 要求完成下面任意一个任务 找一条结点数不少于n/k的简单路径 找k个简单环, 每个环结点数小于n/k, 且不为3的倍数, 且每个环有一个特殊点 ...
- LD_PRELOAD的偷梁换柱之能
作者: net66 原创 本文网址:http://www.cnblogs.com/net66/p/5609026.html 发布日期:2015 年 06月 22日 一.LD_PRELOAD是什么 LD ...
- spring boot 学习(六)spring boot 各版本中使用 log4j2 记录日志
spring boot 各版本中使用 log4j2 记录日志 前言 Spring Boot中默认日志工具是 logback,只不过我不太喜欢 logback.为了更好支持 spring boot 框架 ...
- 跟我一起学习ASP.NET 4.5 MVC4.0(四)
前几个文章中介绍了一些关于MVC4.0的东东,今天我们来看一下登陆验证,也可以说是权限验证,即AuthorizeAttribute.这个可以使用在控制器Controller上,也可以使用在Action ...