結果

問題 No.3149 find X which satisfies with equlation
ユーザー mkzkm
提出日時 2025-05-20 21:50:08
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,966 bytes
コンパイル時間 1,825 ms
コンパイル使用メモリ 198,784 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-05-20 21:50:11
合計ジャッジ時間 2,876 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 44
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define mod99 998244353
#define endl "\n"
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)
#define prep(i,a,n) for (ll i = a; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(), a.rend()
#define si(x) ((ll)(x).size())
#define YN(bool) if(bool){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yn(bool) if(bool){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define PRE(x) cout << fixed << setprecision(x)
#define Yes cout << "Yes\n"
#define No cout << "No\n"
#define YES cout << "YES\n"
#define NO cout << "NO\n"
template <typename T> inline T gcd(T a,T b) {return (b==0)?a:gcd(b,a%b);}
template <typename T> inline T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define sq(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
const ld PI=3.141592653589793238462643383279;
const ld EPS=0.00000001;
const ll INF=1000000000000000000LL;
//string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//string abc = "abcdefghijklmnopqrstuvwxyz";

bool issub(string s,string t){
  ll i=0;
  for(char c:t){
    if(i<si(s)&&s[i]==c) i++;
   }
  return i==si(s);
}
bool isprime(ll N){
  if(N<2) return false;
  for(ll i=2; i*i<=N; i++) if(N%i==0) return false;
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  
  ll a, b;cin >> a >> b;
  vector<ll> p, q, memo;
  while(a!=0) {p.push_back(a%2); a/=2;}
  while(b!=0) {q.push_back(b%2); b/=2;}
  ll n=si(p), m=si(q);
  if(n>m) rep(i,n-m) q.push_back(0);
  if(n<m) rep(i,m-n) p.push_back(0);
  reverse(all(p));reverse(all(q));
  rep(i,si(p)) {
    if(p[i]!=q[i]) memo.push_back(1);
    else memo.push_back(0);
  }
  ll ans = 0;
  ll t = 1;
  for(int i=si(memo)-1;i>=0;i--) {
    if(memo[i]==1) ans+=t;
    t*=2;
  }
  cout << ans << endl;
}
0