結果
| 問題 |
No.1298 OR XOR
|
| コンテスト | |
| ユーザー |
Tsukasan_z46
|
| 提出日時 | 2020-12-13 00:55:35 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,054 bytes |
| コンパイル時間 | 2,527 ms |
| コンパイル使用メモリ | 194,644 KB |
| 最終ジャッジ日時 | 2025-01-16 23:08:35 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 13 |
ソースコード
#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;
}
Tsukasan_z46