結果

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

ソースコード

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 (int j=1, l=1; j<=n; j+=pow(k, l), l++) {
        cnt++;
      }
      printf("%d\n", cnt);
    }
  }
  return 0;
}
0