結果
| 問題 |
No.1871 divisXor
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-03-18 20:24:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 901 bytes |
| コンパイル時間 | 1,019 ms |
| コンパイル使用メモリ | 84,724 KB |
| 実行使用メモリ | 7,328 KB |
| 最終ジャッジ日時 | 2025-03-18 20:24:13 |
| 合計ジャッジ時間 | 6,464 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 4 WA * 25 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
void check_bits(int num) {
vector<int> result;
int msb = 31; // Assuming 32-bit integer
while (msb >= 0 && ((num >> msb) & 1) == 0) {
msb--;
}
if (msb < 0) { // If num is 0
cout << "1\n1" << endl;
return;
}
int counter = 1;
result.push_back(1 << msb);
for (int i = msb - 1; i >= 0; i--) {
int bit = (num >> i) & 1;
if (bit == 0 && counter) {
result.push_back(1 << i);
counter = 0;
} else if (bit == 1 && counter == 0) {
result.push_back(1 << i);
counter = 1;
}
}
cout << result.size() << "\n";
for (int val : result) {
cout << val << " ";
}
cout << endl;
}
int main() {
int num;
cin >> num;
check_bits(num);
return 0;
}