結果

問題 No.638 Sum of "not power of 2"
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-06-09 04:53:18
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 456 bytes
コンパイル時間 5,831 ms
コンパイル使用メモリ 71,960 KB
実行使用メモリ 57,752 KB
最終ジャッジ日時 2023-09-13 01:39:28
合計ジャッジ時間 6,196 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,768 KB
testcase_01 AC 122 ms
55,660 KB
testcase_02 AC 124 ms
55,940 KB
testcase_03 AC 124 ms
55,684 KB
testcase_04 WA -
testcase_05 AC 120 ms
55,876 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 122 ms
56,200 KB
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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

		long N = sc.nextLong();
		System.out.println(judge(N));
	}

	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