結果
問題 | No.1450 nahco314's First Problem |
ユーザー | neko_the_shadow |
提出日時 | 2021-04-07 10:29:06 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 5,156 bytes |
コンパイル時間 | 3,391 ms |
コンパイル使用メモリ | 80,796 KB |
実行使用メモリ | 37,276 KB |
最終ジャッジ日時 | 2024-04-26 02:07:21 |
合計ジャッジ時間 | 6,177 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
37,220 KB |
testcase_01 | AC | 50 ms
36,944 KB |
testcase_02 | AC | 50 ms
36,716 KB |
testcase_03 | AC | 50 ms
36,964 KB |
testcase_04 | AC | 51 ms
37,220 KB |
testcase_05 | AC | 50 ms
37,040 KB |
testcase_06 | AC | 50 ms
37,132 KB |
testcase_07 | AC | 52 ms
36,700 KB |
testcase_08 | AC | 51 ms
36,712 KB |
testcase_09 | AC | 52 ms
36,692 KB |
testcase_10 | AC | 52 ms
37,128 KB |
testcase_11 | AC | 51 ms
37,124 KB |
testcase_12 | AC | 51 ms
36,984 KB |
testcase_13 | AC | 52 ms
37,156 KB |
testcase_14 | AC | 51 ms
37,036 KB |
testcase_15 | AC | 52 ms
37,192 KB |
testcase_16 | AC | 50 ms
37,180 KB |
testcase_17 | AC | 50 ms
37,128 KB |
testcase_18 | AC | 52 ms
37,064 KB |
testcase_19 | AC | 51 ms
37,020 KB |
testcase_20 | AC | 52 ms
37,040 KB |
testcase_21 | AC | 52 ms
37,276 KB |
testcase_22 | AC | 51 ms
36,676 KB |
testcase_23 | AC | 51 ms
37,120 KB |
testcase_24 | AC | 50 ms
36,980 KB |
testcase_25 | AC | 51 ms
36,804 KB |
testcase_26 | AC | 51 ms
37,056 KB |
testcase_27 | AC | 51 ms
37,040 KB |
testcase_28 | AC | 52 ms
36,836 KB |
testcase_29 | AC | 51 ms
36,816 KB |
testcase_30 | AC | 51 ms
37,020 KB |
testcase_31 | AC | 52 ms
37,144 KB |
testcase_32 | AC | 51 ms
36,716 KB |
testcase_33 | AC | 52 ms
37,052 KB |
testcase_34 | AC | 52 ms
37,048 KB |
testcase_35 | AC | 52 ms
37,036 KB |
testcase_36 | AC | 52 ms
36,716 KB |
testcase_37 | AC | 50 ms
36,696 KB |
testcase_38 | AC | 52 ms
37,180 KB |
testcase_39 | AC | 52 ms
36,968 KB |
ソースコード
import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; import java.io.PrintWriter; import java.io.UncheckedIOException; import java.lang.reflect.Array; import java.util.Objects; public class Main { public void exec() { long x = Long.parseLong(stdin.nextString()); for (long m = 1; m <= 70 ; m++) { long n = x^m; if (n > 0 && Long.bitCount(n)==m) { stdout.println(n); return; } } stdout.println(-1); } private static final Stdin stdin = new Stdin(System.in); private static final Stdout stdout = new Stdout(System.out); private static final Stderr stderr = new Stderr(System.err, false); public static void main(String[] args) { try { new Main().exec(); } finally { stdout.flush(); } } // ASCII ONLY public static class Stdin { private InputStream in; private byte[] buf; private int ptr; private int len; public Stdin(InputStream in) { this.in = in; this.buf = new byte[1024]; this.ptr = 0; this.len = 0; } public String nextString() { StringBuilder sb = new StringBuilder(); byte b; while ((b = read()) != -1) { sb.appendCodePoint(b); } return sb.toString(); } public int nextInt() { return (int)nextLong(); } public double nextDouble() { return Double.parseDouble(nextString()); } public long nextLong() { boolean negative = false; int x = 0; byte b = read(); if (b == '-') { negative = true; } else { x += b-'0'; } while ((b=read()) != -1) { x *= 10; x += b-'0'; } return negative ? -x : x; } private byte read() { byte b = readByte(); if (b == '\r') { readByte(); // LFを読み飛ばす return -1; } else if (b == '\n' || b == ' ') { return -1; } else { return b; } } private byte readByte(){ if (len == ptr) { try { ptr = 0; len = in.read(buf); if (len == -1) return -1; } catch (IOException e) { throw new UncheckedIOException(e); } } return buf[ptr++]; } public String[] nextStringArray(int n) { String[] a = new String[n]; for (int i = 0; i < n; i++) a[i] = nextString(); return a; } public int[] nextIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } public double[] nextDoubleArray(int n) { double[] a = new double[n]; for (int i = 0; i < n; i++) a[i] = nextDouble(); return a; } public long[] nextLongArray(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return a; } } public static class Stdout { private PrintWriter stdout; public Stdout(PrintStream stdout) { this.stdout = new PrintWriter(stdout, false); } public void println(Object ... objs) { for (int i = 0, len = objs.length; i < len; i++) { stdout.print(objs[i]); if (i != len-1) stdout.print(' '); } stdout.println(); } public void flush() { stdout.flush(); } } public static class Stderr { private PrintWriter stderr; private boolean debug; public Stderr(PrintStream stderr, boolean debug) { this.stderr = new PrintWriter(stderr, false); this.debug = debug; } public void println(Object ... objs) { if (!debug) return ; stderr.print("DEBUG: "); for (int i = 0, len = objs.length; i < len; i++) { stderr.print(deepToString(objs[i])); if (i != len-1) stderr.print(' '); } stderr.println(); stderr.flush(); } private String deepToString(Object o) { if (o == null) { return "null"; } // 配列の場合 if (o.getClass().isArray()) { int len = Array.getLength(o); String[] tokens = new String[len]; for (int i = 0; i < len; i++) { tokens[i] = deepToString(Array.get(o, i)); } return "{" + String.join(", ", tokens) + "}"; } return Objects.toString(o); } } }