結果

問題 No.2323 Nafmo、A+Bをする
ユーザー w0t0w0t0
提出日時 2023-05-28 14:07:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 981 bytes
コンパイル時間 1,963 ms
コンパイル使用メモリ 199,892 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-27 09:03:38
合計ジャッジ時間 2,857 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using ull=unsigned long long;
using ldo =long double;
#define rep(i,n,k) for(ll i = k; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1e18;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main() {
  string A,B,C="";
  cin>>A;
  cin>>B;
  rep(i,max(A.size(),B.size())+1,1){
    if(A.size()-i<0)C.push_back(B[A.size()-i]);
    else if(B.size()-i<0)C.push_back(A[B.size()-i]);
    else{
      if((A[A.size()-i]==B[B.size()-i])and(A[A.size()-i]=='1')){
        C.push_back('0');
      }else if((A[A.size()-i]=='1')or('1'==B[B.size()-i])){
        C.push_back('1');
      }else{
        C.push_back('0');
      }
    }
    
  }
  ll a=0,now=1;
  rep(i,C.size(),0){
    if(C[i]=='1')a+=now;
    now*=2;
  }
  cout<<a<<endl;
  return 0;
}
0