結果

問題 No.1651 Removing Cards
ユーザー SSRSSSRS
提出日時 2021-08-20 21:51:15
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 219 ms / 2,000 ms
コード長 441 bytes
コンパイル時間 1,773 ms
コンパイル使用メモリ 165,612 KB
実行使用メモリ 7,628 KB
最終ジャッジ日時 2024-04-22 04:20:11
合計ジャッジ時間 9,986 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 5 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 183 ms
5,376 KB
testcase_10 AC 185 ms
5,376 KB
testcase_11 AC 192 ms
5,376 KB
testcase_12 AC 180 ms
5,376 KB
testcase_13 AC 186 ms
5,376 KB
testcase_14 AC 183 ms
5,376 KB
testcase_15 AC 200 ms
7,628 KB
testcase_16 AC 204 ms
7,500 KB
testcase_17 AC 208 ms
7,496 KB
testcase_18 AC 207 ms
7,500 KB
testcase_19 AC 212 ms
7,376 KB
testcase_20 AC 215 ms
7,376 KB
testcase_21 AC 208 ms
7,496 KB
testcase_22 AC 219 ms
7,500 KB
testcase_23 AC 194 ms
5,376 KB
testcase_24 AC 152 ms
5,376 KB
testcase_25 AC 172 ms
7,628 KB
testcase_26 AC 178 ms
7,264 KB
testcase_27 AC 217 ms
7,500 KB
testcase_28 AC 208 ms
7,372 KB
testcase_29 AC 202 ms
7,628 KB
testcase_30 AC 203 ms
7,500 KB
testcase_31 AC 200 ms
7,624 KB
testcase_32 AC 170 ms
5,376 KB
testcase_33 AC 171 ms
5,376 KB
testcase_34 AC 173 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int K, Q;
  cin >> K >> Q;
  vector<long long> A;
  A.push_back(1);
  while (true){
    long long nxt = A.back() + (A.back() + K - 2) / (K - 1);
    A.push_back(nxt);
    if (nxt > 2000000000000000000){
      break;
    }
  }
  for (int i = 0; i < Q; i++){
    long long N;
    cin >> N;
    auto itr = upper_bound(A.begin(), A.end(), N);
    itr--;
    cout << *itr << endl;
  }
}
0