結果

問題 No.638 Sum of "not power of 2"
ユーザー Daigo HIROOKA
提出日時 2018-06-09 04:59:49
言語 Java
(openjdk 23)
結果
AC  
実行時間 163 ms / 1,000 ms
コード長 552 bytes
コンパイル時間 3,459 ms
コンパイル使用メモリ 77,176 KB
実行使用メモリ 55,944 KB
最終ジャッジ日時 2024-06-30 12:23:21
合計ジャッジ時間 6,207 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class No638{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		long N = sc.nextLong();
		long result = judge(N);
		if(result == -1) System.out.println(result);
		else System.out.println(result + " " + (N-result));

	}

	private static long judge(long N){
		if(N < 3) return -1;
		
		for(long a = 3; a <= N/2; a++){
			if(!is2pow(a) && !is2pow(N-a)){
				return a;
			}
		}
		return -1;
	}
	private static boolean is2pow(long a){
		if((a & (a-1)) == 0) return true;
		else return false;
	}
}
0