Emiliatan

b003

Feb 23rd, 2019
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. /* b003           */
  2. /* AC (0ms, 68KB) */
  3. #include <cstdio>
  4.  
  5. using namespace std;
  6.  
  7. typedef long long int64;
  8.  
  9. int main()
  10. {
  11.     for(int64 n, sum = 0, cnt = 0; ~scanf("%lld", &n); sum = 0, cnt = 0)
  12.     {
  13.         if(n < 0) n = (~n) + 1;
  14.         while(sum < n) sum += (++cnt);
  15.         while((sum - n) & 1) sum += (++cnt);
  16.         printf("%lld\n", cnt);
  17.     }
  18.     return 0;
  19. }
Add Comment
Please, Sign In to add comment