結果

問題 No.638 Sum of "not power of 2"
ユーザー GrenacheGrenache
提出日時 2018-02-12 12:31:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 146 ms / 1,000 ms
コード長 770 bytes
コンパイル時間 5,223 ms
コンパイル使用メモリ 80,848 KB
実行使用メモリ 41,936 KB
最終ジャッジ日時 2024-05-03 06:58:13
合計ジャッジ時間 6,626 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
41,500 KB
testcase_01 AC 142 ms
41,376 KB
testcase_02 AC 140 ms
41,712 KB
testcase_03 AC 140 ms
41,936 KB
testcase_04 AC 145 ms
41,724 KB
testcase_05 AC 141 ms
41,736 KB
testcase_06 AC 146 ms
41,588 KB
testcase_07 AC 142 ms
41,624 KB
testcase_08 AC 145 ms
41,784 KB
testcase_09 AC 141 ms
41,616 KB
testcase_10 AC 142 ms
41,420 KB
testcase_11 AC 142 ms
41,728 KB
testcase_12 AC 143 ms
41,476 KB
testcase_13 AC 140 ms
41,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder638 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		long n = sc.nextLong();

		Set<Long> hs = new HashSet<>();
		for (int i = 0; i < 61; i++) {
			hs.add(1L << i);
		}

		for (long i = 3; i <= n - i; i++) {
			if (hs.contains(i) || hs.contains(n - i)) {
				continue;
			}

			pr.printf("%d %d\n", i, n - i);
			return;
		}

		pr.println(-1);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0