Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int t;
- cin>>t;
- while(t--){
- int n;
- cin>>n;
- long long int cnt4 = 0;
- long long int cnt6 = 0;
- long long int ans = 0;
- for(int i=0; i<n; i++){
- int x;
- cin>>x;
- if(x == 4) ans += cnt4;
- if(x == 2) ans += cnt6;
- cnt6 += (x == 6);
- cnt4 += (x == 4);
- }
- cout<<ans<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement