結果
| 問題 |
No.2323 Nafmo、A+Bをする
|
| コンテスト | |
| ユーザー |
hiro71687k
|
| 提出日時 | 2023-06-07 23:38:50 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 2,000 ms |
| コード長 | 981 bytes |
| コンパイル時間 | 1,917 ms |
| コンパイル使用メモリ | 195,296 KB |
| 最終ジャッジ日時 | 2025-02-13 23:18:45 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll inf=20000000000000;
ll mod=998244353;
int main(){
string a,b;
cin >> a >> b;
if (a.size()<b.size())
{
reverse(a.begin(),a.end());
while (a.size()!=b.size())
{
a.push_back('0');
}
reverse(a.begin(),a.end());
}else{
reverse(b.begin(),b.end());
while (a.size()!=b.size())
{
b.push_back('0');
}
reverse(b.begin(),b.end());
}
for (ll i = 0; i < a.size(); i++)
{
if (a[i]=='0'&&b[i]=='1')
{
a[i]='1';
}else if (a[i]=='1'&&b[i]=='1')
{
a[i]='0';
}
}
reverse(a.begin(),a.end());
ll now=1;
ll ans=0;
for (ll i = 0; i < a.size(); i++)
{
if (a[i]=='1')
{
ans+=now;
}
now*=2;
}
cout << ans << endl;
}
hiro71687k