#include <cstdio>
#include <cmath>
#include <cstdlib>
int main() {
int t;
scanf("%d", &t);
while (t--) {
int n, num;
scanf("%d", &num);
num = abs(num);
n = int(sqrt(num));
while (n * (n + 1) / 2 < num) {
n++;
}
while (n * (n + 1) % 2 == 0 && (n * (n + 1) / 2 - num) % 2 != 0) {
n++;
}
if (num == 0)
printf("3\n");
else
printf("%d\n", n);
if (t)
printf("\n");
}
return 0;
}
UVA 10025 The ? 1 ? 2 ? ... ? n = k problem
最新推荐文章于 2024-05-19 21:24:51 发布