zoj 3432 与运算运用
2015-01-29 11:37
363 查看
/****************************************************
该题充分运用与运算的特点,成对消除,单的最后留下
****************************************************/
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
char str1[10], str2[10];
int n;
while(~scanf("%d", &n) )
{
getchar();
gets(str1);
for(int i=0; i<2*n-2; i++)
{
gets(str2);
for(int j=0; j<7; j++)
str1[j] = str1[j] ^ str2[j]; //两个字符串各自与运算,可以判定最后剩下的不成对的一个
}
printf("%s\n", str1);
}
}
/*
Description
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
*/
[/code]
来自为知笔记(Wiz)
附件列表
相关文章推荐
- ZOJ 3432 Find the Lost Sock (异或的运用)
- zoj 3432 神奇的位运算。。
- 运用智能型平台管理界面(IPMI)管理与监控高效能运算丛集 (转贴)
- 位运算的运用
- ZJU/ZOJ Deque and Balls 3929 计数:小的情况对总情况的贡献。 小心mod运算陷阱
- zoj 3432 字符串 位运算
- zoj 3596 BFS+大数简单运算
- 位运算基本概念及简单运用
- zoj 3432 Find the Lost Sock
- zoj 3870 Team Formation(位运算,超时)
- 小学生四则运算出题程序 无操作界面java版 简单的运用java中一些基本操作
- ZOJ 3447 Doraemon's Number Game(优先队列+高精度运算)
- ZOJ-2091-Mean of Subsequence (反证法的运用!!)
- 位运算的运用
- Zoj 3870 Team Formation(异或运算)
- 【C#食谱】【风味小吃】菜单4 对各种数据类型运用位运算符求补运算符
- 在C语言中运用全局变量返回函数的数组运算结果(Lu Hongling)
- zoj 2615 Cells 栈的运用
- zoj 3432 Find the Lost Sock(解决时间超时问题)
- HDU 1021/ZOJ 2060 Fibonacci Again(数论&整除推导&位运算技巧)