Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int N = 1e5+2;
- long long sum [N] ;
- int main()
- {
- int n ;
- long long ans;
- long long *srch;
- for (int i = 0 ; i<N ; ++i)
- {
- sum[i] = (1ll*i*(i+1))/2.0;
- }
- i:
- cin >> n ;
- n = (n<0 ? -n : n);
- srch = lower_bound(sum,sum+N,n);
- ans = srch - sum ;
- if (*srch != n) ++ans;
- if (*srch != n && n&1 ) ++ans;
- cout << ans <<endl ;
- goto i ;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement