Submission #881996

# Submission time Handle Problem Language Result Execution time Memory
881996 2023-12-02T11:46:16 Z vjudge1 Odd-even (IZhO11_oddeven) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define sp << " " << 
#define int long long
#define vi vector<int>
#define F(xxx,yyy) for (int xxx=1;xxx<=yyy;xxx++)
#define pii pair<int,int>
const int N = 1e5+1,inf = 1e18;
void solve() {
  string nn;
  cin >> nn;
  if (nn.size() <= 19) {
    int n = stoi(nn);
    if(n<=1e18) {
    int l=1;
    int r=2e9;
    while (l<=r) {
      int m = (l+r)/2;
      if (m*(m+1)/2 <= n) l = m+1;
      else r = m-1;
    }
    int x = r*(r-1)/2;
    cout << n+x+(n-r*(r+1)/2)/2 << endl;
    }
    else cout << -1 << endl;
  }
  else cout << -1 << endl;
}
    
                  
                             
signed main() { 
  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  #ifdef Local
  freopen("in","r",stdin);
  freopen("out","w",stdout);
  #endif
  int t = 1;
  //cin >> t;
	F(i,t) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -