結果

問題 No.897 compαctree
ユーザー michonz4
提出日時 2020-01-05 07:52:22
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 344 bytes
コンパイル時間 135 ms
コンパイル使用メモリ 29,952 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-22 21:56:13
合計ジャッジ時間 747 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <math.h>

int main() {
  int q;
  scanf("%d", &q);

  for (int i=0; i<q; i++) {
    int n, k, cnt=0;
    scanf("%d %d", &n, &k);

    if (k==1) {
      printf("%d\n", n-1);
    } else{
      for (long long j=1, l=1; j<=n; j+=pow(k, l), l++) {
        cnt++;
      }
      printf("%d\n", cnt);
    }
  }
  return 0;
}
0