Advertisement
Ankit_132

B

Feb 28th, 2024
839
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int t;
  6.     cin>>t;
  7.    
  8.     while(t--){
  9.         int n;
  10.         cin>>n;
  11.        
  12.         if(n%2 == 0)
  13.         {
  14.             int x = n/2;
  15.             cout<<(x*1ll*(x+1))<<"\n";
  16.         }
  17.         else
  18.         {
  19.             int x = n/2;
  20.             cout<<(x*1ll*(x+1)) + (n+1)/2<<"\n";
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement