結果

問題 No.1298 OR XOR
ユーザー pengin_2000
提出日時 2021-07-11 06:45:33
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 332 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 29,184 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-02 02:58:33
合計ジャッジ時間 1,028 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i, j;
	int cnt = 0;
	int a[3] = { 0,0,0 };
	for (j = 0, i = 1; n > 0; n /= 2, i *= 2)
	{
		if (n % 2 > 0)
		{
			cnt++;
			a[j] += i;
			j = (j + 1) % 3;
			a[j] += i;
		}
	}
	if (cnt == 1)
		a[0] = a[1] = a[2] = -1;
	printf("%d %d %d\n", a[0], a[1], a[2]);
	return 0;
}
0