QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#228808 | #5822. 城市建设 | Terryjoy | Compile Error | / | / | C++14 | 894b | 2023-10-28 14:16:38 | 2023-10-28 14:16:38 |
Judging History
This is the latest submission verdict.
- [2023-10-28 14:16:38]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2023-10-28 14:16:38]
- Submitted
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for (int i = a; i <= (b); i++)
#define drep(i, a, b) for (int i = a; i >= (b); i--)
typedef long long ll;
int n, c;
ll ccc(int x) {
return (1ll * x * x - x % 2) / 4;
}
ll cal(int num) {
int a = n / num, b = a + 1, cb = n % num, ca = num - cb;
ll tot;
if (num == 1)
tot = 0;
else {
tot = n - 1;
if (cb >= 2) {
tot -= 2 * (b / 2);
} else if (cb == 1) {
tot -= b / 2 + a / 2;
} else
tot -= 2 * (a / 2);
}
return tot + 1ll * num * c + ccc(a) * ca + ccc(b) * cb;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> c;
int l = 1, r = n;
for (int i = 1; i <= 100; ++i) {
int lm = l + (r - l) / 3, rm = r - (r - l) / 3;
if (cal(lm) < cal(rm))
r = rm;
else
l = lm;
}
ll ans = 1e18;
ans = min(ans, cal(i))
cout << ans;
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:40:28: error: ‘i’ was not declared in this scope 40 | ans = min(ans, cal(i)) | ^