1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
#include <iostream> using namespace std; unsigned long long int T[60001]; int main() { int t,n,c=0; int r,pos; T[1]=1; for(int i=2;i<60001;i++) T[i]=T[i-1]+i; //cout<<T[60000]<<"\n"; cin>>t; c=t; int k=0; while(t--) { cin>>n; if(k!=c &&k!=0) cout<<"\n"; k++; if(n==0) { cout<<3<<"\n"; continue; } if(n==1) { cout<<2<<"\n"; continue; } if(n<0) n*=-1; for(int i=1;i<60001;i++) { if(T[i]>=n) { r= T[i]; pos=i; break; } } int d=r-n; if(d==0 || d%2==0) { cout<<pos<<"\n"; continue; } while((T[pos]-n)%2==1) { pos++; } cout<<pos<<"\n"; } return 0; } |