結果

問題 No.3547 Rurumaru Function Problem
コンテスト
ユーザー Shymohn _
提出日時 2026-05-22 22:30:34
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,418 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,085 ms
コンパイル使用メモリ 330,300 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-22 22:30:41
合計ジャッジ時間 6,347 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using u64 = uint64_t;
using pqi = priority_queue<int>;
using dqi = deque<int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define llrep(i, n) for (LL i = 0; i < (int)(n); i++)
#define nrep(i, s, n) for (int i = s; i < n; i++)
#define drep(i, n) for (int i = (n) - 1; i >= 0; i--;)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pb push_back
#define mp make_pair
#define int long long
const int INF = 1e17;
const double pi = 3.14159265358979;
const int mod = 998244353;
const int MOD = 1000000007;

//sni:tmp,pi,vvc,no,NO,yes,YES,vi,keta,pq,gpq

signed main(){

 ios::sync_with_stdio(false);
 std::cin.tie(nullptr);
 int n,m;
 cin>>n>>m;

 int ans = 0;
 int it = 1;
 int kn = n;
 int km = m;
 int i = 0;
 while(kn>0||km>0){
    int xn = kn%2;
    int xm = km%2;
    kn /= 2;
    km /= 2;
    if(i%2==0){
        if(xm==1){
            if(xn==0){
                cout << -1 << endl;
                return 0;
            }
            else ans += it;
            
        }
    }
    else {
        if(xm==1){
            if(xn==0)ans += it;
        }
        if(xm==0&&xn==1){
            cout << -1 << endl;
            return 0;
        }
    }
    i++;
    it *= 2;

 }
 cout << ans << endl;


}
0