#include "hack.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pii pair<ll, ll>
ll calcCnt(ll n, ll mid) {
ll cnt = 0;
cnt += (n / mid) * (n / mid - 1) / 2 * mid;
// cout << n << " " << mid << " -> " << cnt << " ";
cnt += (n % mid) * (n / mid);
// cout << cnt << "\n";
return cnt;
}
ll n = 1e6;
ll bs(ll col) {
ll lo = 1;
ll hi = n;
while (lo < hi) {
ll mid = (lo + hi) / 2;
ll cnt = calcCnt(n, mid);
// cout << mid << " - " << cnt << "\n";
if (cnt > col) lo = mid + 1;
else hi = mid;
}
return lo;
}
int hack() {
// for (int i = 1; i <= 1000; i++) {
// cout << i << " - " << calcCnt(n, i) << "\n";
// }
//
// cout << "\n";
//
// cout << calcCnt(n, 499999) << "\n";
// cout << calcCnt(n, 16667) << "\n";
// cout << calcCnt(n, 1) << "\n";
cout << "\n";
// cout << bs(0) << "\n";
// cout << bs(1) << "\n";
// cout << bs(1000000) << "\n";
// cout << bs(1000004) << "\n";
// cout << bs(1767864320) << "\n";
vector <ll> v;
for (ll i = 0; i < n; i++) v.push_back(i);
ll x = collisions(v);
return bs(x);
}
//int main() {
// hack();
//}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |