상한 1e10으로 하니까 accept 받네,,,
이거 나가서 탈락했는데 너무 아쉽다 ㅠ
void process(int tc) {
ll L, R; scanf("%lld%lld", &L, &R);
int f = 0;
if (L
ll ans = 0, s = 0, e = 1e9, m, c = L - R, r;
while (s <= e) {
m = (s + e) / 2LL;
if (m * (m + 1) / 2LL <= c) {
s = m + 1;
ans = m;
}
else e = m - 1;
}
L -= ans * (ans + 1LL) / 2LL;
if (f && L == R)f = 0;
if (ans + 1LL <= L) {
s = 1; e = 1e9; r = 0;
while (s <= e) {
m = (s + e) / 2LL;
if (ans + m <= L / m) {
s = m + 1;
r = m;
}
else e = m - 1;
}
m = r;
L -= m * (ans + m);
if (R >= m * (ans + m + 1LL)) {
R -= m * (ans + m + 1LL);
ans++;
}
else R -= (m - 1LL) *(ans + m);
ans += 2LL * (m - 1LL) + 1LL;
}
if (f) swap(L, R);
printf("Case #%d: %lld %lld %lld\n", tc, ans, L, R);
}
https://codingcompetitions.withgoogle.com/codejam/round/000000000019ffb9/00000000003384ea
LR 조건이 1e18 이라 가져가는 사람 수를 1e9로 상한을 정해도 되야하는거 아니가??
1에서 1e9까지 수를 다 더하면 5e17정도니까 안되지
아하
그렇구나 고마워
난 2.5e9 함
1e10으로 하면 롱롱도 오버플로나지않아?
오버플로 나는데 이분매칭 과정에서 나오는 middle 값에선 안나오는 듯