結果

問題 No.638 Sum of "not power of 2"
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-22 19:13:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 160 ms / 1,000 ms
コード長 489 bytes
コンパイル時間 2,429 ms
コンパイル使用メモリ 76,476 KB
実行使用メモリ 55,156 KB
最終ジャッジ日時 2024-04-10 06:33:30
合計ジャッジ時間 4,862 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
52,792 KB
testcase_01 AC 126 ms
54,156 KB
testcase_02 AC 115 ms
52,808 KB
testcase_03 AC 109 ms
53,108 KB
testcase_04 AC 138 ms
54,800 KB
testcase_05 AC 121 ms
54,252 KB
testcase_06 AC 149 ms
54,952 KB
testcase_07 AC 158 ms
55,004 KB
testcase_08 AC 160 ms
54,892 KB
testcase_09 AC 159 ms
54,856 KB
testcase_10 AC 156 ms
55,156 KB
testcase_11 AC 160 ms
54,788 KB
testcase_12 AC 128 ms
54,256 KB
testcase_13 AC 142 ms
54,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		long n = sc.nextLong();
		int i = 1;
		
		boolean  b = false;
		for (; i<n; i++) {
			if (check(i)==false && check(n-i)==false) {b=true; break;}
		}
		
		if (b==true) {System.out.println(i+" "+(n-i));}
		else {System.out.println(-1);}
	}
	
	static boolean check (long n) {
		while (n != 1) {
			if (n%2 == 1) {return false;}
			n /= 2;
		}
		return true;
	}
}
0