# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
379079 | gustason | Uzastopni (COCI17_uzastopni) | C++14 | 1093 ms | 364 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18 + 5;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
ll n;
cin >> n;
for(int i = 2; i*i <= 3 * n; i++) {
// if (i % 2 == 0 && n % i != i/2) continue;
// if (i % 2 && n % i != 0) continue;
ll l = 1, r = n;
while(l <= r) {
ll mid = (l + r) / 2;
ll a0 = mid, an = mid + i - 1;
if (a0 + an > INF / i || (i * (a0 + an)) / 2 > n) {
r = mid - 1;
} else if ((i * (a0 + an)) / 2 == n) {
cout << a0 << " " << an << "\n";
break;
} else {
l = mid + 1;
}
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |