結果
問題 | No.638 Sum of "not power of 2" |
ユーザー | denderaKawazu |
提出日時 | 2018-02-13 19:07:17 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,329 bytes |
コンパイル時間 | 2,214 ms |
コンパイル使用メモリ | 77,708 KB |
実行使用メモリ | 59,328 KB |
最終ジャッジ日時 | 2023-08-20 05:33:36 |
合計ジャッジ時間 | 5,174 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 128 ms
55,504 KB |
testcase_01 | WA | - |
testcase_02 | AC | 121 ms
55,712 KB |
testcase_03 | WA | - |
testcase_04 | AC | 151 ms
56,328 KB |
testcase_05 | WA | - |
testcase_06 | AC | 152 ms
56,948 KB |
testcase_07 | AC | 158 ms
56,904 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 123 ms
55,904 KB |
testcase_13 | AC | 149 ms
54,604 KB |
ソースコード
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.HashSet; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; Scanner in = new Scanner(inputStream); PrintWriter out = new PrintWriter(outputStream); Task solver = new Task(); solver.solve(1, in, out); out.close(); } static class Task { static HashSet<Long> twoPow = new HashSet<>(); static void setTwoPow(long max) { long n = 2; while (n < max) { twoPow.add(n); n *= 2; } } public void solve(int testNumber, Scanner in, PrintWriter out) { long n = in.nextLong(); setTwoPow(n); long a = n / 2; long b = n - a; while (a > 0 && twoPow.contains(a) || twoPow.contains(b)) { a--; b++; } if (a <= 0) { out.println(-1); } else { out.println(a + " " + b); } } } }