zoukankan      html  css  js  c++  java
  • B

    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代码:
     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 int main(){
     4     char s[105],t[105],r[105];
     5     memset(r,'',sizeof(r));
     6     cin>>s>>t;
     7     for(int i=0;s[i]!='';++i){
     8         if(s[i]==t[i])r[i]='0';
     9         else r[i]='1';
    10     }
    11     cout<<r<<endl;
    12     return 0;
    13 }
     
  • 相关阅读:
    分享一个Fluent风格的邮件发送封装类
    写一个ActionFilter检测WebApi接口请求和响应
    一道有趣的面试题,小鸟和火车的问题
    Centos7 查看Mysql配置文件
    Centos7 grep命令简介
    Centos7 网络配置
    django之python3.4及以上连接mysql的一些问题记录
    NetCore log4net 集成以及配置日志信息不重复显示或者记录
    ionic3中关于Ionic ui component使用的一些总结
    ionic2升级到ionic3并打包APK
  • 原文地址:https://www.cnblogs.com/acgoto/p/9159204.html
Copyright © 2011-2022 走看看