Submission #522593

#TimeUsernameProblemLanguageResultExecution timeMemory
522593Be_dosOdd-even (IZhO11_oddeven)C++17
0 / 100
614 ms296 KiB
#include <iostream> #include <cmath> #include <cctype> #include <vector> #include <algorithm> #include <set> #include <map> #include <deque> #include <stack> #include <unordered_set> #include <sstream> #include <cstring> #include <iomanip> #include <queue> #include <unordered_map> #include <random> #include <cfloat> #include <chrono> #include <bitset> #include <complex> #include <immintrin.h> #include <cassert> int64_t int_sqrt(int64_t n) { int64_t res = 0; for(int64_t i = 1; i * i < n; i++) res = i; return res + 1; } int main() { int64_t n; std::cin >> n; int64_t block = (int_sqrt(1 + 8 * n)) / 2; int64_t block_end = block * (block + 1) / 2; int64_t block_start = block_end - block + 1; std::cout << block_start + (block - 1) * (block - 2) / 2 + (n - block_start) * 2; return 0; } //0 0 1 3 6 10 //1, 2, 4, 5, 7, 9, 10, 12, 14, 16, 17 19 21 23 25 26 //1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
#Verdict Execution timeMemoryGrader output
Fetching results...