This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
using namespace std;
int gcd (int a, int b) { return b == 0 ? a : gcd(b, a%b); }
int n, a[100], g[100][100], w[100], c;
bool used[100];
int res;
void solve (int x) {
if(x == n) { ++res; return; }
solve(x+1);
for(int i = 0; i < c; i++) {
if(gcd(a[x], a[w[i]]) > 1) return;
}
w[c++] = x;
solve(x+1);
w[--c] = 0;
}
int main() {
scanf("%d", &n);
for(int i = 0; i < n; i++) scanf("%d", a+i);
solve(0);
res -= n+1;
printf("%d\n", res);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |