結果

問題 No.1651 Removing Cards
ユーザー risujiroh
提出日時 2021-08-20 23:25:03
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 436 bytes
コンパイル時間 2,012 ms
コンパイル使用メモリ 195,700 KB
最終ジャッジ日時 2025-01-24 00:38:50
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int k;
  cin >> k;
  vector<int64_t> a{1};
  while (true) {
    a.push_back((__int128_t(a.back()) * k + k - 2) / (k - 1));
    if (a.back() > 1e18) {
      break;
    }
  }

  int q;
  cin >> q;
  while (q--) {
    int64_t n;
    cin >> n;
    cout << *prev(upper_bound(begin(a), end(a), n)) << '\n';
  }
}
0