#include <bits/stdc++.h>
using namespace std;
void solve() {
double n;cin>>n;
int x = ceil((sqrt(n*8+1)-1)/2);
if(x%2==1){
int d = (x+1)/2-1;
x--;
cout << (d*d*4+1)+(2*(n-(x*(x+1)/2)-1));
} else {
int d = x/2-1;
x--;
cout << (d*d*4+4*d+2)+(2*(n-(x*(x+1)/2)-1));
}
}
int main() {
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
388 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |