結果

問題 No.1298 OR XOR
ユーザー tentententen
提出日時 2022-09-26 18:09:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 1,365 bytes
コンパイル時間 2,097 ms
コンパイル使用メモリ 74,948 KB
実行使用メモリ 54,128 KB
最終ジャッジ日時 2023-08-24 02:59:17
合計ジャッジ時間 4,808 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
52,348 KB
testcase_01 AC 43 ms
49,356 KB
testcase_02 AC 42 ms
49,272 KB
testcase_03 AC 43 ms
49,344 KB
testcase_04 AC 44 ms
49,588 KB
testcase_05 AC 43 ms
47,396 KB
testcase_06 AC 79 ms
53,804 KB
testcase_07 AC 84 ms
53,636 KB
testcase_08 AC 79 ms
53,636 KB
testcase_09 AC 79 ms
53,608 KB
testcase_10 AC 82 ms
53,732 KB
testcase_11 AC 79 ms
53,712 KB
testcase_12 AC 79 ms
54,128 KB
testcase_13 AC 82 ms
53,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int x = sc.nextInt();
        int idx = 0;
        while (true) {
            if ((x & (1 << idx)) == 0) {
                idx++;
                continue;
            }
            if ((x ^ (1 << idx)) == 0) {
                System.out.println("-1 -1 -1");
            } else {
                int a = (1 << idx);
                int b = x ^ a;
                System.out.println(a + " " + b + " " + x);
            }
            return;
        }
    }
}
    
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0