結果

問題 No.638 Sum of "not power of 2"
ユーザー htensai
提出日時 2019-11-14 08:30:30
言語 Java
(openjdk 23)
結果
AC  
実行時間 148 ms / 1,000 ms
コード長 464 bytes
コンパイル時間 2,357 ms
コンパイル使用メモリ 76,552 KB
実行使用メモリ 42,428 KB
最終ジャッジ日時 2024-09-21 21:20:23
合計ジャッジ時間 5,022 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		HashSet<Long> set = new HashSet<>();
		for (long i = 1; i <= Math.pow(10, 18); i *= 2) {
		    set.add(i);
		}
		for (long i = 3; i <= n / 2; i++) {
		    if (!set.contains(i) && !set.contains(n - i)) {
		        System.out.println(i + " " + (n - i));
		        return;
		    }
		}
		System.out.println(-1);
	}
}
0