算法
(枚举) $O(100000)$
注意到 PIN
码只有4位,所以直接枚举 $0000 \sim 9999$,并判断当前这个数是否包含了所有带有 o
的数字,以及不包含所有带有 x
的数字。
C++ 代码
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using std::cin;
using std::cout;
using std::vector;
using std::string;
int main() {
string s;
cin >> s;
int ans = 0;
rep(num, 10000) {
vector<int> a(10);
int x = num;
rep(i, 4) {
int d = x % 10;
a[d] = 1;
x /= 10;
}
bool ok = true;
rep(i, 10) {
if (s[i] == 'o' and a[i] != 1) ok = false;
if (s[i] == 'x' and a[i] != 0) ok = false;
}
if (ok) ++ans;
}
cout << ans << '\n';
return 0;
}