結果

問題 No.638 Sum of "not power of 2"
ユーザー takeya_okinotakeya_okino
提出日時 2019-09-17 19:35:49
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 618 bytes
コンパイル時間 2,229 ms
コンパイル使用メモリ 73,912 KB
実行使用メモリ 56,912 KB
最終ジャッジ日時 2023-09-21 20:14:12
合計ジャッジ時間 5,096 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,608 KB
testcase_01 AC 121 ms
56,260 KB
testcase_02 AC 120 ms
55,820 KB
testcase_03 AC 120 ms
56,008 KB
testcase_04 AC 120 ms
56,188 KB
testcase_05 WA -
testcase_06 AC 146 ms
56,508 KB
testcase_07 AC 146 ms
56,692 KB
testcase_08 AC 146 ms
56,728 KB
testcase_09 WA -
testcase_10 AC 146 ms
56,796 KB
testcase_11 AC 147 ms
56,768 KB
testcase_12 AC 120 ms
55,632 KB
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    String ans = "-1";
    if(n == 6) ans = 3 + " " + 3;
    if(n > 6) { 
      for(long i = 3; i <= 6; i++) {
        if(i != 4) {
          long t = n - i;
          int p = 0;
          if((t > 1) && (t % 2 == 1)) p++;
          while(t % 2 == 0) {
            t /= 2;
            if(t % 2 == 1) p++;
          }
          if(p > 0) {
            ans = i + " " + (n - i);
            break;
          } 
        }
      }
    }
    System.out.println(ans);
  }
}
0