pratiyush7

Untitled

Mar 23rd, 2022
1,016
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.26 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void mainSolve()
  5. {
  6.   int n;
  7.   cin >> n;
  8.   int ans = (n % 2 == 0) ? n / 2 : -(n + 1) / 2;
  9.   cout << ans << endl;
  10. }
  11.  
  12. int main()
  13. {
  14.   int t;
  15.   cin >> t;
  16.   while (t--)
  17.   {
  18.     mainSolve();
  19.   }
  20.   return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment