답안 #379765

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
379765 2021-03-19T09:07:01 Z SolarSystem 홀-짝 수열 (IZhO11_oddeven) C++17
0 / 100
1 ms 512 KB
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long long n;
    cin >> n;

    long long l = 0, r = 1e18;

    while (l + 1 < r) {
        long long m = (l + r) / 2;

        if ((long double) m > (long double) 2e18 / (m + 1) || m * (m + 1) / 2 > n) {
            r = m;
        } else {
            l = m;
        }
    }

    if (l * (l + 1) / 2 == n) cout << l * l;
    else {
        cout << l * l + (n - l * (l + 1) / 2) * 2 - 1;
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 512 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Incorrect 1 ms 364 KB Output isn't correct
14 Halted 0 ms 0 KB -