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], x[100];
int main() {
scanf("%d", &n);
for(int i = 0; i < n; i++) scanf("%d", a+i);
int res = 0;
for(int state = 0; state < (1<<n); state++) {
int c = 0;
for(int i = 0; i < n; i++) if((state >> i) & 1) x[c++] = i;
if(c <= 1) continue;
bool s = true;
for(int i = 0; i < c && s; i++) {
for(int j = i+1; j < c && s; j++) {
if(gcd(a[x[i]], a[x[j]]) >= 2) s = false;
}
}
if(s) {
++res;
//for(int i = 0; i < c; i++) printf("%s%d%s", (i == 0) ? "{" : "", a[x[i]], ((i == c-1) ? "}\n": ", "));
}
}
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... |