結果

問題 No.1651 Removing Cards
ユーザー 沙耶花沙耶花
提出日時 2021-08-20 22:27:43
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 617 ms / 2,000 ms
コード長 1,150 bytes
コンパイル時間 4,525 ms
コンパイル使用メモリ 254,888 KB
実行使用メモリ 9,172 KB
最終ジャッジ日時 2024-04-22 05:13:12
合計ジャッジ時間 18,641 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 129 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 204 ms
6,940 KB
testcase_10 AC 197 ms
6,940 KB
testcase_11 AC 203 ms
6,940 KB
testcase_12 AC 203 ms
6,940 KB
testcase_13 AC 211 ms
6,944 KB
testcase_14 AC 202 ms
6,944 KB
testcase_15 AC 605 ms
7,504 KB
testcase_16 AC 596 ms
8,016 KB
testcase_17 AC 609 ms
9,172 KB
testcase_18 AC 591 ms
7,760 KB
testcase_19 AC 586 ms
8,660 KB
testcase_20 AC 586 ms
8,528 KB
testcase_21 AC 588 ms
7,628 KB
testcase_22 AC 600 ms
7,376 KB
testcase_23 AC 211 ms
6,940 KB
testcase_24 AC 168 ms
6,940 KB
testcase_25 AC 568 ms
8,148 KB
testcase_26 AC 551 ms
8,784 KB
testcase_27 AC 617 ms
8,272 KB
testcase_28 AC 615 ms
8,144 KB
testcase_29 AC 608 ms
7,756 KB
testcase_30 AC 605 ms
7,884 KB
testcase_31 AC 607 ms
8,404 KB
testcase_32 AC 182 ms
6,944 KB
testcase_33 AC 186 ms
6,940 KB
testcase_34 AC 188 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000000000001


int main(){
	
	long long K,Q;
	cin>>K>>Q;
	
	vector<long long> S(1,0);
	S.push_back(1);
	
	while(true){
		long long aa = S[S.size()-2];
		long long ok = Inf,ng = S.back();
		while(ok-ng>1LL){
			long long mid = (ok+ng)/2;
			
			long long t = (mid-1)/K;
			t++;
			if(mid-t>=S.back())ok = mid;
			else ng = mid;
		}
		//if(S.back()==3)cout<<aa<<','<<ok<<endl;
		S.push_back(ok);
		if(S.back()>=Inf)break;
		
	}
	/*
	vector<long long> pos(S.size(),0);
	pos[1] = 1;
	
	for(int i=2;i<S.size();i++){
		long long t = pos[i-1];
		long long ok = Inf,ng = t;
		while(ok-ng>1LL){
			long long mid = (ok+ng)/2;
			long long tt = (mid-1)/K;
			tt++;
			if(mid-tt>=t)ok = mid;
			else ng = mid;
		}
		if((ok-1)%K==0)ok++;
		pos[i] = ok;
	}
	*/
	/*
	rep(i,10){
		cout<<S[i]<<endl;
	}*/
	
	
	
	rep(_,Q){
		long long N;
		cin>>N;
		
		int d = distance(S.begin(),upper_bound(S.begin(),S.end(),N));
		d--;
		cout<<S[d]<<endl;
	}
	
	return 0;
}
0