結果

問題 No.638 Sum of "not power of 2"
ユーザー kusagame12kusagame12
提出日時 2023-11-11 21:39:09
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 890 bytes
コンパイル時間 2,783 ms
コンパイル使用メモリ 77,072 KB
実行使用メモリ 58,852 KB
最終ジャッジ日時 2023-11-11 21:39:15
合計ジャッジ時間 6,186 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
57,700 KB
testcase_01 AC 149 ms
57,700 KB
testcase_02 AC 141 ms
57,668 KB
testcase_03 AC 145 ms
57,780 KB
testcase_04 AC 180 ms
56,908 KB
testcase_05 AC 139 ms
57,956 KB
testcase_06 AC 167 ms
58,764 KB
testcase_07 AC 168 ms
58,852 KB
testcase_08 AC 165 ms
58,832 KB
testcase_09 WA -
testcase_10 AC 165 ms
58,732 KB
testcase_11 AC 184 ms
58,736 KB
testcase_12 AC 142 ms
57,676 KB
testcase_13 AC 170 ms
58,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        long n = sc.nextLong();
        
        long ansA = -1;
        long ansB = -1;
        for(long b = n - 2 ; b > 1 ; b--){
            
            long a = n - b;
            
            if((b % 2 == 0 && !myJudge(b)) || (a % 2 == 0 && !myJudge(a))){
                continue;
            }
            
            ansA = a;
            ansB = b;
            break;
            
        }
        
        System.out.println(ansA == -1 ? -1 : ansA+" "+ansB);
           
    }
    
    private static boolean myJudge(long num){
        
        for(int i = 1 ; i < 61 ; i++){
            if(num == Math.pow(2 , i)){
                return false;
            }
        }
        return true;
        
    }
    
}
0