제출 #7367

#제출 시각아이디문제언어결과실행 시간메모리
7367tncks0121경비원 (GA8_guard)C++98
8 / 100
2000 ms20444 KiB
#include <cstdio> using namespace std; int gcd (int a, int b) { return b == 0 ? a : gcd(b, a%b); } int n, a[2225], g[2225][2225], w[2225], c; bool used[2225]; int res; void solve (int x) { if(x == n) { for(int i = 0; i < c; i++) { for(int j = i+1; j < c; j++) { if(gcd(a[w[i]], a[w[j]]) > 1) return; } } ++res; return; } solve(x+1); 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); for(int i = 0; i < n; i++) { for(int j = i+1; j < n; j++) { g[i][j] = g[j][i] = gcd(a[i], a[j]); } } solve(0); res -= n+1; 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...