結果

問題 No.2323 Nafmo、A+Bをする
ユーザー tanadaaatanadaaa
提出日時 2023-05-28 13:48:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 972 bytes
コンパイル時間 1,680 ms
コンパイル使用メモリ 167,448 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 08:29:39
合計ジャッジ時間 2,553 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<long>;
using vll = vector<long long>;
using vs = vector<string>;
using vc = vector<char>;
using pll = pair<long long, long long>;
const int INF = 1e9;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

ll baseN_to_base10(string n, ll b){
    reverse(n.begin(), n.end());
    long long res = 0;
    ll m = n.size();
    ll count = 1;
    for(int i = 0; i < m; i++){
        res += (n[i] - '0')*count;
        count *= b;
    }
    return res;
}

int main() {
  string a,b;
  cin >> a >> b;
  bitset<30> x(a),y(b);
  string f;
  rep(i,30){
    if(x.test(i) && y.test(i))f = '0' + f;
    else if(!x.test(i) && y.test(i))f = '1' + f;
    else if(x.test(i) && !y.test(i))f = '1' + f;
    else if(!x.test(i) && !y.test(i))f = '0' + f;
  }
  cout << baseN_to_base10(f,2) << endl;
}
0