結果

問題 No.1450 nahco314's First Problem
ユーザー tentententen
提出日時 2023-04-17 10:39:15
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,835 bytes
コンパイル時間 2,890 ms
コンパイル使用メモリ 96,404 KB
実行使用メモリ 50,628 KB
最終ジャッジ日時 2024-04-26 02:13:40
合計ジャッジ時間 6,400 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 54 ms
50,296 KB
testcase_01 AC 54 ms
50,336 KB
testcase_02 AC 56 ms
50,500 KB
testcase_03 WA -
testcase_04 AC 53 ms
50,116 KB
testcase_05 AC 53 ms
50,552 KB
testcase_06 AC 56 ms
50,168 KB
testcase_07 AC 53 ms
50,568 KB
testcase_08 AC 53 ms
50,336 KB
testcase_09 AC 53 ms
50,476 KB
testcase_10 AC 54 ms
50,444 KB
testcase_11 AC 53 ms
50,436 KB
testcase_12 AC 53 ms
50,376 KB
testcase_13 AC 53 ms
50,432 KB
testcase_14 AC 53 ms
50,072 KB
testcase_15 AC 53 ms
50,492 KB
testcase_16 AC 53 ms
50,628 KB
testcase_17 AC 55 ms
50,516 KB
testcase_18 AC 53 ms
50,460 KB
testcase_19 AC 53 ms
50,432 KB
testcase_20 AC 53 ms
50,064 KB
testcase_21 AC 54 ms
50,488 KB
testcase_22 AC 55 ms
50,440 KB
testcase_23 AC 56 ms
50,016 KB
testcase_24 AC 52 ms
50,440 KB
testcase_25 AC 53 ms
49,912 KB
testcase_26 AC 52 ms
50,484 KB
testcase_27 AC 54 ms
50,380 KB
testcase_28 AC 54 ms
49,932 KB
testcase_29 AC 55 ms
50,040 KB
testcase_30 AC 53 ms
50,312 KB
testcase_31 AC 53 ms
50,024 KB
testcase_32 AC 52 ms
50,412 KB
testcase_33 AC 53 ms
50,444 KB
testcase_34 AC 54 ms
50,120 KB
testcase_35 AC 52 ms
50,116 KB
testcase_36 AC 54 ms
50,540 KB
testcase_37 AC 54 ms
50,184 KB
testcase_38 AC 54 ms
50,480 KB
testcase_39 AC 54 ms
50,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        long k = sc.nextLong();
        for (long i = Math.max(0, k - 65); i <= k + 65; i++) {
            if ((i ^ getPop(i)) == k) {
                System.out.println(i);
                return;
            }
        }
        System.out.println(-1);
    }
    
    static long getPop(long x) {
        long pop = 0;
        while (x > 0) {
            pop += x % 2;
            x >>= 1;
        }
        return pop;
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
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 int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0