結果
| 問題 |
No.897 compαctree
|
| コンテスト | |
| ユーザー |
forest3
|
| 提出日時 | 2020-03-27 15:28:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 472 bytes |
| コンパイル時間 | 1,482 ms |
| コンパイル使用メモリ | 160,552 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-01-02 08:37:19 |
| 合計ジャッジ時間 | 1,884 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 13 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
long long power( long long x, long long n )
{
long long res = 1;
while( n > 0 ) {
if( n % 2 ) res = res * x;
x = x * x;
n /= 2;
}
return res;
}
int main()
{
int Q;
cin >> Q;
for( int q = 0; q < Q; q++ ) {
long long N, K;
cin >> N >> K;
long long n = 0;
if( K == 1 ) n = N - 1;
else {
long long nn = 1;
while( nn < N ) {
nn += power( K, n + 1 );
n++;
}
}
cout << n << endl;
}
}
forest3