結果

問題 No.1298 OR XOR
ユーザー tentententen
提出日時 2020-11-30 18:22:12
言語 Java21
(openjdk 21)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 610 bytes
コンパイル時間 2,259 ms
コンパイル使用メモリ 74,200 KB
実行使用メモリ 57,216 KB
最終ジャッジ日時 2023-10-11 02:58:01
合計ジャッジ時間 5,525 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 159 ms
56,564 KB
testcase_01 AC 122 ms
55,924 KB
testcase_02 AC 121 ms
56,180 KB
testcase_03 AC 126 ms
55,988 KB
testcase_04 AC 120 ms
55,736 KB
testcase_05 AC 123 ms
56,524 KB
testcase_06 AC 160 ms
57,216 KB
testcase_07 AC 159 ms
57,064 KB
testcase_08 AC 160 ms
57,184 KB
testcase_09 AC 159 ms
56,608 KB
testcase_10 AC 163 ms
57,076 KB
testcase_11 AC 163 ms
57,016 KB
testcase_12 AC 161 ms
56,940 KB
testcase_13 AC 164 ms
57,032 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