結果

問題 No.1298 OR XOR
ユーザー tenten
提出日時 2020-11-30 18:22:12
言語 Java
(openjdk 23)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 610 bytes
コンパイル時間 2,711 ms
コンパイル使用メモリ 83,100 KB
実行使用メモリ 55,000 KB
最終ジャッジ日時 2024-09-13 02:28:21
合計ジャッジ時間 5,401 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

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