結果

問題 No.2416 vs Slime
ユーザー hiromi_ayasehiromi_ayase
提出日時 2023-08-12 14:24:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 52 ms / 2,000 ms
コード長 2,029 bytes
コンパイル時間 3,106 ms
コンパイル使用メモリ 77,932 KB
実行使用メモリ 37,652 KB
最終ジャッジ日時 2024-04-30 05:55:06
合計ジャッジ時間 5,277 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
37,516 KB
testcase_01 AC 46 ms
37,544 KB
testcase_02 AC 46 ms
37,484 KB
testcase_03 AC 45 ms
37,488 KB
testcase_04 AC 46 ms
37,504 KB
testcase_05 AC 46 ms
37,560 KB
testcase_06 AC 46 ms
37,584 KB
testcase_07 AC 45 ms
37,480 KB
testcase_08 AC 45 ms
37,480 KB
testcase_09 AC 46 ms
37,416 KB
testcase_10 AC 46 ms
37,624 KB
testcase_11 AC 48 ms
37,592 KB
testcase_12 AC 47 ms
37,344 KB
testcase_13 AC 48 ms
37,652 KB
testcase_14 AC 46 ms
37,212 KB
testcase_15 AC 48 ms
37,508 KB
testcase_16 AC 52 ms
37,568 KB
testcase_17 AC 51 ms
37,548 KB
testcase_18 AC 50 ms
37,504 KB
testcase_19 AC 51 ms
37,472 KB
testcase_20 AC 51 ms
37,108 KB
testcase_21 AC 51 ms
37,408 KB
testcase_22 AC 51 ms
37,224 KB
testcase_23 AC 50 ms
37,560 KB
testcase_24 AC 51 ms
37,544 KB
testcase_25 AC 50 ms
37,504 KB
testcase_26 AC 50 ms
37,224 KB
testcase_27 AC 49 ms
37,356 KB
testcase_28 AC 49 ms
37,576 KB
testcase_29 AC 47 ms
37,168 KB
testcase_30 AC 46 ms
37,540 KB
testcase_31 AC 46 ms
37,588 KB
testcase_32 AC 47 ms
37,432 KB
testcase_33 AC 45 ms
37,596 KB
testcase_34 AC 46 ms
37,648 KB
testcase_35 AC 49 ms
37,076 KB
testcase_36 AC 50 ms
37,652 KB
testcase_37 AC 50 ms
37,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

@SuppressWarnings("unused")
public class Main {

  private static void solve() {

      long h = nl();
      long a = nl();

      long ret = 0;
      long cnt = 1;
      while (h > 0) {
        h /= a;
        ret += cnt;
        cnt *= 2;
      }
      System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        solve();
        out.flush();
      }
    }, "", 64000000).start();
  }

  private static PrintWriter out = new PrintWriter(System.out);
  private static StringTokenizer tokenizer = null;
  private static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 32768);

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }
}
0