結果

問題 No.378 名声値を稼ごう
ユーザー takeya_okinotakeya_okino
提出日時 2017-06-19 21:59:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 620 bytes
コンパイル時間 4,724 ms
コンパイル使用メモリ 70,500 KB
実行使用メモリ 56,144 KB
最終ジャッジ日時 2023-09-12 13:06:36
合計ジャッジ時間 5,181 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,896 KB
testcase_01 AC 126 ms
55,520 KB
testcase_02 AC 125 ms
56,104 KB
testcase_03 AC 124 ms
55,936 KB
testcase_04 AC 124 ms
56,144 KB
testcase_05 AC 124 ms
55,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long normal = 0;
    long score = N;
    for(int i = 0; i < 61; i++) {
      if(score > 0) {
        normal += score;
        score /= 2;
      } else {
        break;
      }
    }
    long skill = 0;
    for(int i = 0; i < 61; i++) {
      score = N;
      long a = 0;
      for(int j = 0; j < i; j++) {
        a += score;
        score /= 2;
      }
      a += (2 * score);
      skill = Math.max(skill, a);
    }
    System.out.println(skill - normal);
  }
}
0