QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#838847 | #9864. Coin | lxllxs | WA | 0ms | 3532kb | C++20 | 1.1kb | 2025-01-01 02:20:03 | 2025-01-01 02:20:03 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
typedef unsigned long long ull;
typedef long long ll;
const int N = 2e5 + 5, M = 2e5 + 5, LGN = 20, mod = 998244353, B = 131, inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f, P = 1000000711;
int n, k;
int calc(int x, int ct) {
int res = x / k * ct, p = x % k;
if (p) {
int d = x / k + 1;
res += min((p - 1) / d + 1, ct);
}
return x - res;
}
int f(int x) {
if (x == 1)return 1;
int pt = (x + k - 1) / k, l = 1, r = (x - 1) / pt;
while (l < r) {
int mid = l + r >> 1;
if ((x - pt * mid + k - 1) / k < pt)r = mid;
else l = mid + 1;
}
int p = f(x - pt * l), ct = l;
l = 1, r = x;
while (l < r) {
int mid = l + r >> 1;
if (calc(mid, ct) >= p)r = mid;
else l = mid + 1;
}
return l;
}
void lxllxs() {
cin >> n >> k;
cout << f(n) << endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int t = 1;
// cin >> t;
while (t--)lxllxs();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3532kb
input:
4 6 2 8 3 10000 2 1919810 114514
output:
4
result:
wrong answer Answer contains longer sequence [length = 4], but output contains 1 elements