結果
| 問題 |
No.2323 Nafmo、A+Bをする
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-28 13:48:59 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 972 bytes |
| コンパイル時間 | 1,839 ms |
| コンパイル使用メモリ | 169,936 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-26 21:58:21 |
| 合計ジャッジ時間 | 2,836 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#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;
}