結果

問題 No.1298 OR XOR
ユーザー tentententen
提出日時 2020-11-30 18:21:25
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 612 bytes
コンパイル時間 3,273 ms
コンパイル使用メモリ 73,352 KB
実行使用メモリ 57,044 KB
最終ジャッジ日時 2023-10-11 02:57:55
合計ジャッジ時間 7,110 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 168 ms
56,828 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 161 ms
56,684 KB
testcase_07 AC 158 ms
56,820 KB
testcase_08 AC 160 ms
56,932 KB
testcase_09 AC 156 ms
56,608 KB
testcase_10 AC 157 ms
56,656 KB
testcase_11 AC 161 ms
57,044 KB
testcase_12 AC 168 ms
56,816 KB
testcase_13 AC 162 ms
56,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = getCount(n);
        if (count <= 1) {
            System.out.println("-1, -1, -1");
            return;
        }
        int a = 1;
        while ((n & a) == 0) {
            a <<= 1;
        }
        System.out.println(a + " " + (n ^ a) + " " + n);
    }
    
    static int getCount(int x) {
        int count = 0;
        while (x > 0) {
            count += x % 2;
            x /= 2;
        }
        return count;
    }
}
0