fork download
  1. /*
  2. " وَكَانَ فَضْلُ اللَّهِ عَلَيْكَ عَظِيمًا "
  3.  
  4. ╔░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╗
  5. ║ ║
  6. ║ ███╗ ███╗ ██████╗ ██╗ ██╗ █████╗ ███╗ ███╗ ███████╗ ██████╗ ║
  7. ║ ████╗ ████║██╔═══██╗██║ ██║ ██╔══██╗ ████╗ ████║ ██╔════╝ ██╔══██╗ ║
  8. ║ ██╔████╔██║██║ ██║███████║ ███████║ ██╔████╔██║ █████╗ ██║ ██║ ║
  9. ║ ██║╚██╔╝██║██║ ██║██╔══██║ ██╔══██║ ██║╚██╔╝██║ ██╔══╝ ██║ ██║ ║
  10. ║ ██║ ╚═╝ ██║╚██████╔╝██║ ██║ ██║ ██║ ██║ ╚═╝ ██║ ███████╗ ██████╔╝ ║
  11. ║ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚═════╝ ║
  12. ║ ║
  13. ║ ██╗ ██╗ ██████╗ ███████╗ ███████╗ █████╗ ███╗ ███╗ ║
  14. ║ ██║ ██║ ██╔═══██╗ ██╔════╝ ██╔════╝ ██╔══██╗ ████╗ ████║ ║
  15. ║ ███████║ ██║ ██║ ███████╗ ███████╗ ███████║ ██╔████╔██║ ║
  16. ║ ██╔══██║ ██║ ██║ ╚════██║ ╚════██║ ██╔══██║ ██║╚██╔╝██║ ║
  17. ║ ██║ ██║ ╚██████╔╝ ███████║ ███████║ ██║ ██║ ██║ ╚═╝ ██║ ║
  18. ║ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝ ╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ║
  19. ║ ║
  20. ╚░░░░░░░░░░░░░░░░░░░░░░░ MOHAMED HOSSAM | SOFTWARE ENGINEER ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╝
  21. */
  22.  
  23. #include"bits/stdc++.h"
  24. using namespace std;
  25. #define el '\n'
  26. #define ll long long
  27. #define int long long
  28. #define yes cout << "YES\n"
  29. #define no cout << "NO\n"
  30. #define all(x) (x).begin(), (x).end()
  31. #define rall(x) x.rbegin(), x.rend()
  32. #define sz(x) ((int)(x).size())
  33.  
  34. template<class T, class U>
  35. T GCD(T a, U b) { return (!b ? a : GCD(b, a % b)); }
  36.  
  37. template<class T, class U>
  38. T LCM(T a, U b) { return ((a / GCD(a, b)) * b); }
  39.  
  40. template<class Ta, class Tb>
  41. bool chmax(Ta &a, Tb b) {
  42. if (a >= b) return false;
  43. a = b;
  44. return true;
  45. }
  46.  
  47. template<class Ta, class Tb>
  48. bool chmin(Ta &a, Tb b) {
  49. if (a <= b) return false;
  50. a = b;
  51. return true;
  52. }
  53.  
  54. constexpr ll MAX = 300000, MOD = 998244353, MAXN = 2e5 + 10, inf = 1e18;
  55. using vi = vector<int>;
  56. int dx[] = {-1, 1, 0, 0};
  57. int dy[] = {0, 0, -1, 1};
  58. inline void free_palestine() {
  59. ios_base::sync_with_stdio(false);
  60. cin.tie(NULL);
  61. cout.tie(NULL);
  62.  
  63. #ifndef ONLINE_JUDGE
  64. freopen("inputs.txt", "r", stdin);
  65. freopen("output.txt", "w", stdout);
  66. #endif
  67. }
  68.  
  69. template<typename T>
  70. istream &operator>>(istream &in, vector<T> &v) {
  71. for (auto &x: v) in >> x;
  72. return in;
  73. }
  74.  
  75. template<typename T>
  76. ostream &operator<<(ostream &out, const vector<T> &v) {
  77. for (const auto &x: v) out << x << ' ';
  78. return out;
  79. }
  80. int cal(int n) {
  81. return n * (n + 1) / 2;
  82. }
  83. void solve(int tc) {
  84. int n;cin>>n;
  85. n = abs(n);
  86. if (n==0) {
  87. cout<<0<<el;
  88. return;
  89. }
  90. int need = 1;
  91. while (cal(need) < n) {
  92. //cout<<need<<endl;
  93. need++;
  94. }
  95. cout<<need<<el;
  96. }
  97.  
  98. int32_t main() {
  99. free_palestine();
  100. // freopen("collectingofficer.in", "r", stdin);// freopen("palindrome.out", "w", stdout);
  101. int tc = 1;
  102.  
  103. cin >> tc;
  104. for (int i = 1; i <= tc; ++i) {
  105. solve(i);
  106. }
  107.  
  108. /*
  109.   ⢸⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⡷⠀⠀
  110.   ⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ ⠀⠢⣀⠀⠀
  111.   ⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇ Did you get accepted, son?
  112.   ⢸⠀⠀⠀⠀ ⠖⠒⠒⠒⢤⠀⠀⠀⠀⠀⡇⠀⠀
  113.   ⢸⠀⠀⣀⢤⣼⣀⡠⠤⠤⠼⠤⡄⠀⠀⡇⠀
  114.   ⢸⠀⠀⠑⡤⠤⡒⠒⠒⡊⠙⡏⠀⢀⠀⡇⠀
  115.   ⢸⠀⠀⠀⠇⠀⣀⣀⣀⣀⢀⠧⠟⠁ ⡇
  116.   ⢸⠀⠀⠀⠸⣀⠀⠀⠈⢉⠟⠓⠀⠀⠀⢀⡇⠀⠀
  117.   ⢸⠀⠀⠀⠀⠈⢱⡖⠋⠁⠀⠀⠀⠀⠀⡇⠀⡇
  118.   ⢸⠀⠀⠀⠀⣠⢺⠧⢄⣀⠀⠀⣀⣀⠀⡇⠀⡇
  119.   ⢸⠀⠀⠀⣠⠃⢸⠀⠀⠈⠉⡽⠿⠯⡆⡇
  120.   ⢸⠀⠀⣰⠁⠀⢸⠀⠀⠀⠀⠉⠉⠉⠀⡇⠀⡇
  121.   ⢸⠀⠀⠣⠀⠀⢸⢄⠀⠀⠀⠀⠀⠀⠀⡇⠀⡇⠀
  122.   ⢸⠀⠀⠀⠀⠀⢸⠀⢇⠀⠀⠀⠀⠀⠀⡇⠀⡇
  123.   ⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉⠉
  124.   */
  125. }
  126.  
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
0