#include <bits/stdc++.h>
using namespace std;
void solve() {
double n;cin>>n;
int x = ceil((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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |