momo2345

board moves

Jul 19th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define sunil ios::sync_with_stdio(0);cin.tie(0); cout.tie(0)
  3. using namespace std;
  4. int main()
  5. {
  6.     sunil;
  7.     int t;
  8.     cin>>t;
  9.     while(t--){
  10.         int n,j;
  11.         cin>>n;
  12.         long long x,ans=0,mvs=1;
  13.         for(int i=3;i<=n;i+=2){
  14.          j=i-2;
  15.             ans+=(i*i - j*j)*mvs;
  16.             mvs++;
  17.         }
  18.         cout<<ans<<endl;
  19.     }
  20.  
  21. }
Add Comment
Please, Sign In to add comment