Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ID: mickyta1
- TASK: crypt1
- LANG: C++
- */
- #include <bits/stdc++.h>
- using namespace std;
- const int N = 10;
- int arr[N + 1];
- bool isInSet[10];
- bool checkSet(int x){
- while(x > 0){
- int lastDigit = x % 10;
- if(!isInSet[lastDigit]){
- return false;
- }
- x /= 10;
- }
- return true;
- }
- bool has3Digit(int x){
- return 100 <= x && x < 1000;
- }
- bool has4Digit(int x){
- return 1000 <= x && x < 10000;
- }
- int main(){
- freopen("crypt1.in", "r", stdin);
- freopen("crypt1.out", "w", stdout);
- int n;
- scanf("%d", &n);
- for(int i = 1; i <= n; ++i){
- scanf("%d", &arr[i]);
- isInSet[arr[i]] = true;
- }
- int cnt = 0;
- for(int a = 1; a <= n; ++a){
- if(arr[a] == 0){
- continue;
- }
- for(int b = 1; b <= n; ++b){
- for(int c = 1; c <= n; ++c){
- int fst = 100 * arr[a] + 10 * arr[b] + arr[c];
- for(int d = 1; d <= n; ++d){
- if(arr[d] == 0 || !has3Digit(fst * arr[d])){
- continue;
- }
- for(int e = 1; e <= n; ++e){
- int snd = 10 * arr[d] + arr[e];
- if(arr[e] == 0 || !has3Digit(fst * arr[e]) || !has4Digit(fst * snd)){
- continue;
- }
- if(checkSet(fst * arr[d]) && checkSet(fst * arr[e]) && checkSet(fst * snd)){
- ++cnt;
- }
- }
- }
- }
- }
- }
- cout << cnt << '\n';
- fclose(stdin);
- fclose(stdout);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement