結果

問題 No.1298 OR XOR
ユーザー Tsukasan_z46Tsukasan_z46
提出日時 2020-12-13 00:55:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,054 bytes
コンパイル時間 2,201 ms
コンパイル使用メモリ 203,536 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 02:51:43
合計ジャッジ時間 3,147 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
const int dx[] = { 1,  0, -1,  0};
const int dy[] = { 0,  1,  0, -1};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ////////////////////////////////// コード //////////////////////////////////
  ll N; cin >> N;
  vector<int> res;
  ll tmp = N; int cnt = 0;
  while(tmp > 0){
    if(tmp & 1) res.push_back(cnt);
    cnt++;
    tmp >>= 1; 
  }
  if(res.size() < 2){
    cout << "-1 -1 -1" << endl;
    return 0;
  }else{
    int a = res.size(); ll b = 1;
    REP(i, res[a-1]+1){
      if(i == res[a-1]) cout << b << " ";
      b *= 2;
    }
    b = 1; int c = 0;
    REP(i, res[a-1]){
      if(N >> i & 1) c += b;
      b *= 2; 
    }
    cout << c << " ";
  }
  cout << N << endl;
}
0