Problem--61A--Codeforces--A. Ultra-Fast Mathematician
来源:互联网 发布:dm是什么软件 编辑:程序博客网 时间:2024/05/17 19:18
A. Ultra-Fast Mathematician
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard outputShapur 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 1 if 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’,感觉就是每位异或,输出结果
#include<stdio.h>#include<string.h>int main(){ char str1[105],str2[105]; scanf("%s%s",str1,str2); for(int i=0;i<strlen(str1);i++) str1[i]=(str1[i]==str2[i])?'0':'1'; puts(str1);}
#include<stdio.h>#include<string.h>int main(){ char str1[105],str2[105]; scanf("%s%s",str1,str2); for(int i=0;i<strlen(str1);i++) printf("%d",str1[i]^str2[i]);}
- Problem--61A--Codeforces--A. Ultra-Fast Mathematician
- 61A - Ultra-Fast Mathematician
- A. Ultra-Fast Mathematician
- codeforces Ultra-Fast Mathematician
- Codeforces Ultra-Fast Mathematician
- 【^概念】#57 A. Ultra-Fast Mathematician
- Count Like a Mathematician
- Problem - 152A - Codeforces
- codeforces problem/244/A
- codeforces problem/415/A
- codeforces. problem/408/A
- Codeforces Problem 333A
- Codeforces Problem 332A
- A Fast Sudoku Solver: LeetCode Problem
- codeforces problem/416/A 二分
- codeforces 17A Noldbach problem
- 【codeforces 29A】Spit Problem
- CodeForces - 29A - Spit Problem
- 安卓录制音频:使用MediaRecord实现
- opencv 高斯滤波自己实现
- 通过剪枝来避免不必要循环的dfs算法实例,2017年计蒜课模拟赛(五)第六题
- eclipse Maven安装
- string对象处理字符(C++)
- Problem--61A--Codeforces--A. Ultra-Fast Mathematician
- 24点
- pwnable.kr之cmd2
- SQL:查询某张表中是否存在某个字段
- hdu 2200 Eddy's AC难题
- 深入理解C语言的函数调用过程
- 【java】绘制图形
- leetcode题解-88. Merge Sorted Array
- 发布两个高精计算公式