結果

問題 No.2323 Nafmo、A+Bをする
ユーザー kuma0328kuma0328
提出日時 2023-05-28 13:46:56
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 553 bytes
コンパイル時間 2,411 ms
コンパイル使用メモリ 200,460 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-26 21:50:33
合計ジャッジ時間 2,854 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string a, b;
  cin >> a >> b;
  long long ans = 0, two = 1;
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  for (int i = 0; i < 50; i++) {
    if (i >= a.size() && i >= b.size()) break;
    else if (i >= a.size()) {
      if (b[i] == '1') ans += two; 
    } else if (i >= b.size()) {
      if (a[i] == '1') ans += two;
    } else {
      if (!(a[i] == b[i])) ans += two;
    }
    two *= 2;
  }
  cout << ans << endl;
  return 0;
}
0