답안 #884542

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
884542 2023-12-07T16:13:09 Z kokoue 홀-짝 수열 (IZhO11_oddeven) C++14
0 / 100
2 ms 708 KB
#include<bits/stdc++.h>
using namespace std;
unsigned long long n;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>n;
    int cnt2=0;
    int sum=1;
    while(n>1)
    {
   //     cout<<"in with n="<<n<<", sum="<<sum<<", cnt2="<<cnt2<<"\n";
        if(n>cnt2+1) sum+=1+cnt2*2;
        else sum+=(n-1)*2;
        cnt2++;
        if(n<=cnt2) break;
        n-=cnt2;
    }
    cout<<sum<<"\n";
    return 0;
}

Compilation message

oddeven.cpp: In function 'int main()':
oddeven.cpp:14:13: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]
   14 |         if(n>cnt2+1) sum+=1+cnt2*2;
      |            ~^~~~~~~
oddeven.cpp:17:13: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]
   17 |         if(n<=cnt2) break;
      |            ~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 708 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Incorrect 2 ms 348 KB Output isn't correct
8 Halted 0 ms 0 KB -