제출 #7159

#제출 시각아이디문제언어결과실행 시간메모리
7159tncks0121경비원 (GA8_guard)C++98
8 / 100
2000 ms1128 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...