結果

問題 No.638 Sum of "not power of 2"
ユーザー Daigo HIROOKADaigo HIROOKA
提出日時 2018-06-09 04:59:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 156 ms / 1,000 ms
コード長 552 bytes
コンパイル時間 3,577 ms
コンパイル使用メモリ 73,668 KB
実行使用メモリ 56,884 KB
最終ジャッジ日時 2023-09-13 01:39:45
合計ジャッジ時間 6,396 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,792 KB
testcase_01 AC 124 ms
55,920 KB
testcase_02 AC 124 ms
55,832 KB
testcase_03 AC 125 ms
55,380 KB
testcase_04 AC 154 ms
56,708 KB
testcase_05 AC 125 ms
56,072 KB
testcase_06 AC 151 ms
56,684 KB
testcase_07 AC 152 ms
56,844 KB
testcase_08 AC 152 ms
56,432 KB
testcase_09 AC 153 ms
56,740 KB
testcase_10 AC 156 ms
56,780 KB
testcase_11 AC 151 ms
56,884 KB
testcase_12 AC 124 ms
55,736 KB
testcase_13 AC 151 ms
56,812 KB
権限があれば一括ダウンロードができます

ソースコード

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