結果

問題 No.2323 Nafmo、A+Bをする
ユーザー kekenxkekenx
提出日時 2023-08-07 22:27:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 513 bytes
コンパイル時間 2,076 ms
コンパイル使用メモリ 196,564 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-25 16:46:38
合計ジャッジ時間 2,803 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  string a, b;
  cin >> a >> b;
  if (b.size() > a.size())
    swap(a, b);
  for (int i = 0; i < a.size() - b.size(); i++) {
    b = "0" + b;
  }

  
  string c = "";
  for (int i = 0; i < a.size(); i++) {
    if (a[i] != b[i]) 
      c += "1";
    else
      c += "0";
  }

  reverse(c.begin(), c.end());
  long ans = 0;
  for (int i = 0; i < c.size(); i++) {
    if (c[i] == '1')
      ans += (long)pow(2, i);
  }
  cout << ans << '\n';
  return 0;
}
0