結果

問題 No.1651 Removing Cards
ユーザー 夜
提出日時 2021-08-21 07:23:38
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 218 ms / 2,000 ms
コード長 665 bytes
コンパイル時間 1,005 ms
コンパイル使用メモリ 92,296 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2024-04-22 16:52:22
合計ジャッジ時間 9,173 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 182 ms
5,376 KB
testcase_10 AC 198 ms
5,376 KB
testcase_11 AC 183 ms
5,376 KB
testcase_12 AC 188 ms
5,376 KB
testcase_13 AC 182 ms
5,376 KB
testcase_14 AC 189 ms
5,376 KB
testcase_15 AC 210 ms
6,272 KB
testcase_16 AC 202 ms
6,016 KB
testcase_17 AC 210 ms
6,144 KB
testcase_18 AC 218 ms
6,144 KB
testcase_19 AC 215 ms
6,144 KB
testcase_20 AC 208 ms
5,888 KB
testcase_21 AC 212 ms
6,016 KB
testcase_22 AC 202 ms
6,272 KB
testcase_23 AC 189 ms
5,376 KB
testcase_24 AC 150 ms
5,376 KB
testcase_25 AC 168 ms
6,272 KB
testcase_26 AC 174 ms
6,016 KB
testcase_27 AC 211 ms
6,272 KB
testcase_28 AC 212 ms
6,144 KB
testcase_29 AC 198 ms
6,144 KB
testcase_30 AC 205 ms
6,272 KB
testcase_31 AC 213 ms
6,144 KB
testcase_32 AC 181 ms
5,376 KB
testcase_33 AC 177 ms
5,376 KB
testcase_34 AC 173 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long sum[400000];
long long INF = 3000000000000000000;
int main() {
	long long k, q;
	cin >> k >> q;
	sum[0] = 1;
	long long s = 1, i1 = 1;
	for (;; i1++) {
		if (s > INF)break;
		s += (s + k - 2) / (k - 1);
		sum[i1] = s;
	}
	i1++;
	for (int i = 0; i < q; i++) {
		long long n;
		cin >> n;
		auto itr = upper_bound(sum, sum + i1, n);
		itr--;
		cout << *itr << endl;
	}
}
0