Submission #882205

#TimeUsernameProblemLanguageResultExecution timeMemory
882205Mr_HusanboyOdd-even (IZhO11_oddeven)C++17
0 / 100
1 ms600 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "debugger.cpp" #else #define debug(...) #endif template<class T> int len(T &a){ return a.size(); } using ll = unsigned long long; using pii = pair<int,int>; #define all(a) (a).begin(), (a).end() #define ff first #define ss second string fileio = ""; #define int ll mt19937 mt(time(nullptr)); const int mod = 1e9 + 7; const int inf = 1e9; const ll infl = 1e18; const int maxn = 1e5 + 1; void solve(){ ll n;cin >> n; ll l = 1, r = 8e9; while(l <= r){ ll m = (l + r) / 2; if((m + 1) * m / 2 < n){ l = m + 1; }else{ r = m - 1; } } r ++; cout << 2 * n - r; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); auto start = chrono::high_resolution_clock::now(); #ifndef LOCAL if(fileio.size()){ freopen((fileio + ".in").c_str(), "r", stdin); freopen((fileio + ".out").c_str(), "w", stdout); } #endif int testcases = 1; #ifdef Tests cin >> testcases; #endif while(testcases --){ solve(); cout << '\n'; #ifdef LOCAL cout << "_________________________" << endl; #endif } #ifdef LOCAL auto duration = chrono::duration_cast<chrono::microseconds>(chrono::high_resolution_clock::now() - start); cout << "time: " << (double)duration.count()/1000.0 << " milliseconds" << endl; #endif return 0; }

Compilation message (stderr)

oddeven.cpp: In function 'int main()':
oddeven.cpp:49:10: warning: variable 'start' set but not used [-Wunused-but-set-variable]
   49 |     auto start = chrono::high_resolution_clock::now();
      |          ^~~~~
oddeven.cpp:52:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |         freopen((fileio + ".in").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
oddeven.cpp:53:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |         freopen((fileio + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...