結果
| 問題 |
No.638 Sum of "not power of 2"
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-02-13 19:07:17 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,329 bytes |
| コンパイル時間 | 2,418 ms |
| コンパイル使用メモリ | 79,808 KB |
| 実行使用メモリ | 55,312 KB |
| 最終ジャッジ日時 | 2024-11-30 05:47:48 |
| 合計ジャッジ時間 | 5,837 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 5 WA * 7 |
ソースコード
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);
}
}
}
}