Created
February 9, 2014 01:18
-
-
Save KT-Yeh/8892785 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <cmath> | |
using namespace std; | |
int main() | |
{ | |
int Case, k; | |
scanf("%d",&Case); | |
while (Case--){ | |
scanf("%d",&k); | |
k = abs(k); | |
int n = 0; | |
int sum = 0; | |
while (sum < k) sum += (++n); | |
if (k % 2) | |
while (sum % 2 != 1) sum += (++n); | |
else | |
while (sum % 2 != 0) sum += (++n); | |
if (k == 0) printf("3\n"); | |
else printf("%d\n",n); | |
if (Case) printf("\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment