結果

問題 No.1298 OR XOR
ユーザー ks2mks2m
提出日時 2020-11-27 21:33:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 168 ms / 2,000 ms
コード長 549 bytes
コンパイル時間 2,892 ms
コンパイル使用メモリ 73,748 KB
実行使用メモリ 57,016 KB
最終ジャッジ日時 2023-10-01 04:57:27
合計ジャッジ時間 5,718 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 165 ms
56,748 KB
testcase_01 AC 125 ms
55,532 KB
testcase_02 AC 126 ms
55,900 KB
testcase_03 AC 124 ms
55,776 KB
testcase_04 AC 126 ms
55,960 KB
testcase_05 AC 126 ms
55,664 KB
testcase_06 AC 167 ms
56,840 KB
testcase_07 AC 163 ms
57,016 KB
testcase_08 AC 164 ms
56,968 KB
testcase_09 AC 164 ms
56,980 KB
testcase_10 AC 168 ms
56,796 KB
testcase_11 AC 165 ms
56,672 KB
testcase_12 AC 165 ms
56,692 KB
testcase_13 AC 163 ms
56,692 KB
権限があれば一括ダウンロードができます

ソースコード

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 {
					a += 1 << i;
					c += 1 << i;
				}
			}
		}
		if (cnt <= 1) {
			System.out.println("-1 -1 -1");
		} else {
			System.out.println(a + " " + b + " " + c);
		}
	}
}
0