結果

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

ソースコード

diff #

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
typedef pair<pair<int, int>, int> ppi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef bitset<60> Bitset;
const ll INFL = 1LL << 60;
const int INF = 1000000005;
const int MOD = 998244353;//1000000007;
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
bool range(int x,int y,int X,int Y){if(0<=x&&x<X&&0<=y&&y<Y){return true;} return false;}
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cerr<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cerr<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cerr<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cerr<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cerr<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#define debug_ar(v) do{cerr<<#v": ";for(auto x : v) cerr<<x<<' '; cerr<<endl;}while(0)
#else
#define debug(...)
#define debug_ar(v)
#endif
#pragma endregion
//------------------------------------------------------------------------------------------------------------------------------
int main(void) {
    ios::sync_with_stdio(false);cin.tie(nullptr);
    int K,Q;cin>>K>>Q;
    vl num;
    num.push_back(1);
    int i = 0;
    while(num[i]<1LL<<60){
        num.push_back(num[i]+(num[i]+K-2)/(K-1));
        i++;
    }
    ll N;
    while(Q--){
        cin>>N;
        int idx = upper_bound(num.begin(),num.end(),N) - num.begin() - 1;
        cout<<num[idx]<<endl;
    }  
}
0