結果
| 問題 | No.1298 OR XOR | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-11-27 21:27:29 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 909 bytes | 
| コンパイル時間 | 867 ms | 
| コンパイル使用メモリ | 80,540 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-07-23 22:03:27 | 
| 合計ジャッジ時間 | 1,575 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 13 | 
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    long long N;
    cin >> N;
    vector<int> ni(35);
    int ind = 0;
    while(N > 0){
        ni[ind] = N % 2;
        N >>= 1;
        ind++;
    }
    int cnt = 0;
    for(int i = 0; i < 35; i++){
        if(ni[i] == 1) cnt++;
    }
    if(cnt <= 1){
        cout << -1 << ' ' << -1 << ' ' << -1 << endl;
        return 0;
    }
    long long A = 0, B = 0, C = 0;
    int flag = 0;
    for(int i = 0; i < 35; i++){
        if(ni[i] == 1 && flag == 0){
            A += (1LL << i);
            B += (1LL << i);
            flag = 1;
        }
        else if(ni[i] == 1 && flag == 1){
            B += (1LL << i);
            C += (1LL << i);
        }
    }
    cout << A << ' ' << B << ' ' << C << endl;
}
            
            
            
        