結果

問題 No.1298 OR XOR
ユーザー muminmumin
提出日時 2020-11-27 21:30:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 851 bytes
コンパイル時間 1,751 ms
コンパイル使用メモリ 166,496 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-10-01 04:48:13
合計ジャッジ時間 2,485 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> v(35);
    rep(i,31) if(n>>i& 1) v[i] = 1;
    int cnt = 0;
    rep(i,31) cnt += v[i];
    if(cnt <= 1) cout << -1 << ' ' << -1 << ' ' << -1 << endl;
    else{
        cnt = 0;
        vector<int> num(3);
        int tmp = 1;
        rep(i,31){
            if(v[i] == 1){
                if(cnt % 3 == 0) num[0] += tmp, num[1] += tmp;
                if(cnt % 3 == 1) num[1] += tmp, num[2] += tmp;
                if(cnt % 3 == 2) num[2] += tmp, num[0] += tmp;
                cnt++;
            }
            tmp *= 2;
        }
        cout << num[0] << ' ' << num[1] << ' ' << num[2] << endl;
    }
}
0