結果

問題 No.1298 OR XOR
ユーザー ks2mks2m
提出日時 2020-11-27 21:30:19
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 638 bytes
コンパイル時間 3,034 ms
コンパイル使用メモリ 74,484 KB
実行使用メモリ 56,936 KB
最終ジャッジ日時 2023-10-01 04:49:00
合計ジャッジ時間 7,021 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		int a = 0;
		int b = 0;
		int c = 0;
		int cnt = 0;
		for (int i = 0; i < 31; i++) {
			if ((n >> i & 1) == 1) {
				cnt++;
				if (cnt == 1) {
					a += 1 << i;
					b += 1 << i;
				} else if (cnt == 2) {
					a += 1 << i;
					c += 1 << i;
				} else {
					a += 1 << i;
					b += 1 << i;
					c += 1 << i;
				}
			}
		}
		if ((a ^ b ^ c) != 0) {
			System.out.println("-1 -1 -1");
		} else {
			System.out.println(a + " " + b + " " + c);
		}
	}
}
0