Advertisement
Ankit_132

B

Mar 20th, 2024
468
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 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.         long long int cnt4 = 0;
  13.         long long int cnt6 = 0;
  14.         long long int ans = 0;
  15.        
  16.         for(int i=0; i<n; i++){
  17.             int x;
  18.             cin>>x;
  19.            
  20.             if(x == 4)      ans += cnt4;
  21.             if(x == 2)      ans += cnt6;
  22.            
  23.             cnt6 += (x == 6);
  24.             cnt4 += (x == 4);
  25.         }
  26.        
  27.         cout<<ans<<"\n";
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement