結果

問題 No.1450 nahco314's First Problem
ユーザー tentententen
提出日時 2022-09-30 16:29:19
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,378 bytes
コンパイル時間 2,241 ms
コンパイル使用メモリ 77,396 KB
実行使用メモリ 50,636 KB
最終ジャッジ日時 2024-04-26 02:12:15
合計ジャッジ時間 6,382 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
50,172 KB
testcase_01 AC 52 ms
50,280 KB
testcase_02 AC 51 ms
50,252 KB
testcase_03 WA -
testcase_04 AC 49 ms
50,048 KB
testcase_05 AC 51 ms
50,036 KB
testcase_06 AC 49 ms
50,108 KB
testcase_07 WA -
testcase_08 AC 49 ms
50,424 KB
testcase_09 WA -
testcase_10 AC 52 ms
50,464 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 48 ms
50,444 KB
testcase_14 AC 51 ms
50,472 KB
testcase_15 WA -
testcase_16 AC 50 ms
50,500 KB
testcase_17 AC 52 ms
50,480 KB
testcase_18 AC 53 ms
50,360 KB
testcase_19 AC 54 ms
50,420 KB
testcase_20 AC 52 ms
50,444 KB
testcase_21 AC 50 ms
50,380 KB
testcase_22 AC 49 ms
50,476 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 52 ms
50,076 KB
testcase_26 AC 51 ms
50,312 KB
testcase_27 AC 48 ms
50,368 KB
testcase_28 AC 48 ms
50,456 KB
testcase_29 AC 51 ms
50,104 KB
testcase_30 AC 51 ms
50,032 KB
testcase_31 AC 53 ms
50,472 KB
testcase_32 AC 51 ms
50,488 KB
testcase_33 AC 51 ms
50,496 KB
testcase_34 AC 50 ms
50,424 KB
testcase_35 AC 51 ms
49,920 KB
testcase_36 AC 52 ms
49,976 KB
testcase_37 AC 47 ms
50,460 KB
testcase_38 AC 50 ms
50,280 KB
testcase_39 AC 48 ms
50,388 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();
        long n = x;
        n >>= 5;
        n <<= 5;
        for (int i = 0; i < (1 << 6); i++) {
            if (((n + i) ^ getPop(n + i)) == x) {
                System.out.println(n + 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 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