結果

問題 No.1651 Removing Cards
ユーザー tko919tko919
提出日時 2021-08-23 17:33:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 222 ms / 2,000 ms
コード長 778 bytes
コンパイル時間 2,313 ms
コンパイル使用メモリ 196,348 KB
実行使用メモリ 7,624 KB
最終ジャッジ日時 2024-04-25 09:38:35
合計ジャッジ時間 10,736 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 4 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 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 184 ms
5,376 KB
testcase_10 AC 188 ms
5,376 KB
testcase_11 AC 188 ms
5,376 KB
testcase_12 AC 183 ms
5,376 KB
testcase_13 AC 191 ms
5,376 KB
testcase_14 AC 189 ms
5,376 KB
testcase_15 AC 204 ms
7,464 KB
testcase_16 AC 208 ms
7,500 KB
testcase_17 AC 222 ms
7,504 KB
testcase_18 AC 202 ms
7,500 KB
testcase_19 AC 204 ms
7,496 KB
testcase_20 AC 201 ms
7,500 KB
testcase_21 AC 202 ms
7,504 KB
testcase_22 AC 206 ms
7,500 KB
testcase_23 AC 189 ms
5,376 KB
testcase_24 AC 151 ms
5,376 KB
testcase_25 AC 174 ms
7,500 KB
testcase_26 AC 170 ms
7,372 KB
testcase_27 AC 216 ms
7,496 KB
testcase_28 AC 215 ms
7,384 KB
testcase_29 AC 203 ms
7,500 KB
testcase_30 AC 212 ms
7,376 KB
testcase_31 AC 206 ms
7,624 KB
testcase_32 AC 169 ms
5,376 KB
testcase_33 AC 180 ms
5,376 KB
testcase_34 AC 174 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
using ll=long long int;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}



int main(){
   int k,q;
   cin>>k>>q;
   vector<ll> v;
   v.push_back(1);
   for(;;){
      ll nxt=v.back()+(v.back()+k-2)/(k-1);
      if(nxt>1000000000000000000LL)break;
      v.push_back(nxt);
   }
   while(q--){
      ll n;
      cin>>n;
      ll res=*prev(upper_bound(ALL(v),n));
      cout<<res<<'\n';
   }
   return 0;
}
0