結果

問題 No.1298 OR XOR
ユーザー 東前頭十一枚目東前頭十一枚目
提出日時 2020-12-04 19:12:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 428 bytes
コンパイル時間 2,376 ms
コンパイル使用メモリ 198,688 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-13 08:56:03
合計ジャッジ時間 3,582 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 1 ms
4,352 KB
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 1 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>
using namespace std;

void solve(int n) {
	int a = n;
	int b = 0;
	for(int i = 0; i <= 30; ++i) {
		if(a >> i & 1) {
			b = (1 << i);
			break;
		}
	}
	int c = n ^ b;
	if(c == 0) {
		printf("-1 -1 -1\n");
		return;
	}
	assert((a | b) == n);
	assert((b | c) == n);
	assert((c | a) == n);
	assert((a ^ b ^ c) == 0);
	printf("%d %d %d\n", a, b, c);
}

int main() {
	int n; cin >> n;
	solve(n);
	return 0;
}
0