結果

問題 No.1450 nahco314's First Problem
ユーザー tentententen
提出日時 2021-05-07 14:08:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 1,143 bytes
コンパイル時間 2,676 ms
コンパイル使用メモリ 75,056 KB
実行使用メモリ 50,524 KB
最終ジャッジ日時 2024-04-26 02:08:41
合計ジャッジ時間 5,572 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
50,340 KB
testcase_01 AC 51 ms
50,388 KB
testcase_02 AC 50 ms
50,036 KB
testcase_03 AC 52 ms
50,068 KB
testcase_04 AC 52 ms
50,364 KB
testcase_05 AC 52 ms
50,276 KB
testcase_06 AC 52 ms
50,192 KB
testcase_07 AC 51 ms
50,128 KB
testcase_08 AC 51 ms
50,412 KB
testcase_09 AC 53 ms
50,488 KB
testcase_10 AC 53 ms
49,928 KB
testcase_11 AC 54 ms
50,444 KB
testcase_12 AC 51 ms
50,444 KB
testcase_13 AC 55 ms
50,320 KB
testcase_14 AC 51 ms
50,056 KB
testcase_15 AC 53 ms
50,448 KB
testcase_16 AC 52 ms
50,388 KB
testcase_17 AC 52 ms
50,068 KB
testcase_18 AC 52 ms
50,236 KB
testcase_19 AC 51 ms
50,076 KB
testcase_20 AC 53 ms
50,308 KB
testcase_21 AC 52 ms
50,056 KB
testcase_22 AC 55 ms
50,452 KB
testcase_23 AC 52 ms
50,348 KB
testcase_24 AC 51 ms
50,044 KB
testcase_25 AC 55 ms
50,184 KB
testcase_26 AC 54 ms
50,364 KB
testcase_27 AC 54 ms
50,288 KB
testcase_28 AC 53 ms
50,476 KB
testcase_29 AC 52 ms
50,068 KB
testcase_30 AC 51 ms
50,360 KB
testcase_31 AC 52 ms
50,448 KB
testcase_32 AC 54 ms
50,368 KB
testcase_33 AC 52 ms
50,368 KB
testcase_34 AC 51 ms
50,428 KB
testcase_35 AC 51 ms
50,096 KB
testcase_36 AC 56 ms
50,316 KB
testcase_37 AC 53 ms
50,036 KB
testcase_38 AC 51 ms
50,364 KB
testcase_39 AC 51 ms
50,524 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        long x = sc.nextLong();
        for (int i = 1; i < 70; i++) {
            if (getHum(x ^ i) == i) {
                System.out.println(x ^ i);
                return;
            }
        }
        System.out.println(-1);
    }
    
    static int getHum(long x) {
        int hum = 0;
        while (x > 0) {
            hum += x % 2;
            x /= 2;
        }
        return hum;
    }
}

class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0