B - Ultra-Fast Mathematician
Problem description
Shapur was an extremely gifted student. He was great at everything including Combinatorics, Algebra, Number Theory, Geometry, Calculus, etc. He was not only smart but extraordinarily fast! He could manage to sum 1018 numbers in a single second.
One day in 230 AD Shapur was trying to find out if any one can possibly do calculations faster than him. As a result he made a very great contest and asked every one to come and take part.
In his contest he gave the contestants many different pairs of numbers. Each number is made from digits 0 or 1. The contestants should write a new number corresponding to the given pair of numbers. The rule is simple: The i-th digit of the answer is 1if and only if the i-th digit of the two given numbers differ. In the other case the i-th digit of the answer is 0.
Shapur made many numbers and first tried his own speed. He saw that he can perform these operations on numbers of length ∞ (length of a number is number of digits in it) in a glance! He always gives correct answers so he expects the contestants to give correct answers, too. He is a good fellow so he won't give anyone very big numbers and he always gives one person numbers of same length.
Now you are going to take part in Shapur's contest. See if you are faster and more accurate.
Input
There are two lines in each input. Each of them contains a single number. It is guaranteed that the numbers are made from 0 and 1 only and that their length is same. The numbers may start with 0. The length of each number doesn't exceed 100.
Output
Write one line — the corresponding answer. Do not omit the leading 0s.
Examples
Input
1010100
0100101
Output
1110001
Input
000
111
Output
111
Input
1110
1010
Output
0100
Input
01110
01100
Output
00010
解题思路:题目说辣么多,其实就是将两个二进制进行异或运算:相同位上的数字相同,异或结果为0,否则为1,水过!
AC代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
char s[],t[],r[];
memset(r,'\0',sizeof(r));
cin>>s>>t;
for(int i=;s[i]!='\0';++i){
if(s[i]==t[i])r[i]='';
else r[i]='';
}
cout<<r<<endl;
return ;
}
B - Ultra-Fast Mathematician的更多相关文章
- Yarn概述——FAST, RELIABLE, AND SECURE DEPENDENCY MANAGEMENT
		
官网链接:https://yarnpkg.com/lang/en/ 特性 Ultra Fast. Yarn caches every package it downloads so it never ...
 - win8.1硬盘安装ubuntu14.04双系统
		
在网上找了很多方法都失败了,原因是大多数方法都是用mbr方式安装的,如grub4dos,easybcd.以至于连自己都怀疑win8能不能用硬盘安装,差点就去买个u盘来安装了,就在打算放弃的时候在ubu ...
 - jieba.NET与Lucene.Net的集成
		
首先声明:我对Lucene.Net并不熟悉,但搜索确实是分词的一个重要应用,所以这里还是尝试将两者集成起来,也许对你有一参考. 看到了两个中文分词与Lucene.Net的集成项目:Lucene.Net ...
 - Awesome C/C++
		
Awesome C/C++ A curated list of awesome C/C++ frameworks, libraries, resources, and shiny things. In ...
 - Cheatsheet: 2013 08.14 ~ 08.19
		
.NET Lucene.Net ultra fast search for MVC or WebForms site => made easy! C# State Machines HttpCl ...
 - TE.TYCO.AMP/JST 现货资源备份库存表日志记录-2015-04-13
		
行号 品牌 料号 品名规格 库存 1 molex 09-65-2028 Molex 5273-02A 600 2 tyco 103648-2 AMP 03 MTE RCPT HSG SR RIB .1 ...
 - C/C++ 框架,类库,资源集合
		
很棒的 C/C++ 框架,类库,资源集合. Awesome C/C++ Standard Libraries Frameworks Artificial Intelligence Asynchrono ...
 - awesome cpp
		
https://github.com/fffaraz/awesome-cpp Awesome C/C++ A curated list of awesome C/C++ frameworks, lib ...
 - 【干货】国外程序员整理的 C++ 资源大全【转】
		
来自 https://github.com/fffaraz/awesome-cpp A curated list of awesome C/C++ frameworks, libraries, res ...
 - 设备管理 USB ID
		
发现个USB ID站点,对于做设备管理识别的小伙伴特别实用 http://www.linux-usb.org/usb.ids 附录: # # List of USB ID's # # Maintain ...
 
随机推荐
- VR: AR和VR演进哲学
			
Facebook 20亿美元(4亿美元+16亿美元股票换购方式)收购虚拟现实厂商Oculus 引爆AR产业,索尼不温不火逐步演进的头盔项目也该加速了.最近Oculus rift发布了商业版本:Ocul ...
 - asp.net mvc学习入门
			
MVC是什么? M: Model就是我们获取的网页需要的数据 V: View就是我们的aspx页面,注意这是一个不包含后台代码文件的aspx页面.(其实带有.asp.cs文件也不会有编译错误,但是这样 ...
 - 浅谈Json数据格式
			
我们先来看下w3cschool对json的定义: JSON:JavaScript 对象表示法(JavaScript Object Notation). JSON 是存储和交换文本信息的语法.类似 XM ...
 - BZOJ 4698: Sdoi2008 Sandy的卡片 后缀数组 + RMQ + 查分
			
题目描述 Sandy和Sue的热衷于收集干脆面中的卡片. 然而,Sue收集卡片是因为卡片上漂亮的人物形象,而Sandy则是为了积攒卡片兑换超炫的人物模型. 每一张卡片都由一些数字进行标记,第i张卡片的 ...
 - 【转载】解决方案:git@github.com出现Permission denied (publickey)
			
遇到的问题 今天心血来潮,想将intellij上的项目代码放到GitHub上管理. 在进行添加远程库的时候,出现了:git@github.com出现Permission denied (publick ...
 - Log4net日志发布到服务器上日志无法写入
			
log4net在本地执行时候,日志正常写入,但是发布到服务器上的时候,日志就无法正常写入 解决方案: 1.文件权限 在发布到服务器上的时候,可能文件没有写入权限,导致日志无法正常写入 打开IIS 找到 ...
 - 关于DataGridViewComboBoxColumn的二三事
			
近日开发一个基于WinForm的工具,用到了DataGridViewComboBoxColumn. 关于数据: DataGridView的数据源是代码生成的DataTable DataGridView ...
 - GDI 画刷(10)
			
创建画刷 调用 CreateSoildBrush.CreateHatchBrush.CreateBrushIndirect 函数可以创建画刷. CreateSoildBrush:创建实心画刷: Cre ...
 - keycode键盘 按键 - 键码 对应表
			
字母和数字键的键码值(keyCode) 按键 键码 按键 键码 按键 键码 按键 键码 A 65 J 74 S 83 1 49 B 66 K 75 T 84 2 50 C 67 L 76 U 85 3 ...
 - js借助JSONP实现百度搜索框提示效果
			
主要借助百度搜索的API,调用时会存在跨域问题,需要通过JSONP来解决这个问题,代码如下(代码中部分使用ES6语法): HTML <input type="text" id ...