ZCMU-1416-Find the Lost Sock
来源:互联网 发布:淘宝子账号认证失败 编辑:程序博客网 时间:2024/05/21 16:23
1416: Find the Lost Sock
Time Limit: 2 Sec Memory Limit: 128 MBSubmit: 311 Solved: 65
[Submit][Status][Web Board]
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
easafgh
aqwerty
easdfgh
easdfgh
aqwerty
aqwerty
2
0x0abcd
0ABCDEF
0x0abcd
Sample Output
aabcdef
easafgh
0ABCDEF
【解析】
这道题我一直没做出来..现在问了一下才知道了做法...果然自己太笨.言归正传其实这道题的意思就是给你袜子的名字,看哪个名字出现的次数是奇数次就是丢失的袜子,输出这个名字就可以了。其实就是统计那个字符出现了奇数次,出现奇数次的字符我们就要输出。因为袜子总是成双存在的。
#include<iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int a[8][156];int main(){ int n,i,j; char s[8]; while(~scanf("%d",&n)) { memset(a,0,sizeof(a)); for(i=0;i<(2*n)-1;i++) { scanf("%s",s); for(j=0;j<7;j++) { a[j][s[j]]++;//j代表第几位,a[i][j]表示的是第几位的字符出现次数 } } for(i=0;i<7;i++) { for(j=0;j<156;j++) { if(a[i][j]%2==1)//遍历输出就可以了 { printf("%c",j); break; } } } printf("\n"); } return 0;}
0 0
- ZCMU-1416-Find the Lost Sock
- 1416: Find the Lost Sock
- zoj3432——Find the Lost Sock
- zoj 3432 Find the Lost Sock
- zoj 3432 Find the Lost Sock
- 异或解题:Find the Lost Sock
- ZOJ 3432 Find the Lost Sock
- ZOJ 3432 Find the Lost Sock
- ZOJ3432 Find the Lost Sock,异或运算
- zoj 3432 Find the Lost Sock(解决时间超时问题)
- ZOJ 3432 Find the Lost Sock 解题报告
- ZOJ3432 Find the Lost Sock 字符串异或
- ZOJ 3432 Find the Lost Sock(模拟)
- ZOJ3432 Find the Lost Sock(异或运算)
- zoj3432 Find the Lost Sock 亦或的运用
- zoj 3432 Find the Lost Sock(zoj月赛,受打击了 = =)
- ZOJ 3432 Find the Lost Sock
- zoj 3432 Find the Lost Sock (ZOJ Monthly, November 2010)
- poj 2777,hdu 5023 线段树区间染色+lazy+位运算
- 关于GIMP油漆桶工具使用出错的问题
- scrum理解
- 1027. Colors in Mars 解析
- C++的一些知识以及和C语言的不同
- ZCMU-1416-Find the Lost Sock
- java服务器代理线程
- [leetCode刷题笔记]2017.02.07
- EventBus注销的必要性,用实例说明为什么EventBus用完必须注销
- toposort
- windows.event对象介绍
- Webstrom 20163.3刷新页面一直提示未授权的解决方法
- 1028. List Sorting 解析
- Accessibility辅助功能--一念天堂,一念地狱