답안 #524615

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
524615 2022-02-09T16:08:12 Z lukameladze 홀-짝 수열 (IZhO11_oddeven) C++14
0 / 100
1 ms 332 KB
# include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define int long long
using namespace std;
const int N = 3e5 + 5;
int raod,cur,n,le,ri,ans,lef,rem;
main() {
    cin>>n;
    le = 0;
    ri = 1e10;
    while (le <= ri) {
        int mid = (le + ri) / 2;
        if ((mid*(mid + 1))/2 < n) {
            ans = mid;
            le = mid + 1; 
        } else ri = mid - 1;
    }
    lef = ans*ans+1;
    rem = n - (ans*(ans + 1))/2;
    cout<<lef + (rem - 1)*2<<endl;
}

Compilation message

oddeven.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 288 KB Output is correct
13 Incorrect 1 ms 204 KB Output isn't correct
14 Halted 0 ms 0 KB -