結果
| 問題 |
No.638 Sum of "not power of 2"
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-11-11 22:05:29 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 157 ms / 1,000 ms |
| コード長 | 885 bytes |
| コンパイル時間 | 2,103 ms |
| コンパイル使用メモリ | 76,492 KB |
| 実行使用メモリ | 42,544 KB |
| 最終ジャッジ日時 | 2024-09-26 02:54:02 |
| 合計ジャッジ時間 | 4,749 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 12 |
ソースコード
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 - 2l ; b > 1 ; b--){
long a = n - b;
if((b % 2l == 0 && !myJudge(b)) || (a % 2l == 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 == (long) Math.pow(2 , i)){
return false;
}
}
return true;
}
}