Last active
October 19, 2022 00:14
-
-
Save qjatn0120/62292425609bb3862df50294eb5aa040 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int t, n, a, used[12]; | |
int main(){ | |
cin.tie(nullptr), ios::sync_with_stdio(false); | |
cin >> t; | |
while(t--){ | |
cin >> n; | |
for(int i = 0; i < 10; i++) used[i] = 1; | |
while(n--){ | |
cin >> a; | |
used[a] = 0; | |
} | |
int ans = 0; | |
for(int i = 0; i < 10000; i++){ | |
int num1 = i % 10; | |
int num2 = (i / 10) % 10; | |
int num3 = (i / 100) % 10; | |
int num4 = i / 1000; | |
if(used[num1] && used[num2] && used[num3] && used[num4]){ | |
if(!(num1 == num2 && num2 == num3 && num3 == num4)){ | |
if(num1 == num2 && num3 == num4) ans++; | |
else if(num1 == num3 && num2 == num4) ans++; | |
else if(num1 == num4 && num2 == num3) ans++; | |
} | |
} | |
} | |
cout << ans << "\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment