Submission #7366

#TimeUsernameProblemLanguageResultExecution timeMemory
7366tncks0121경비원 (GA8_guard)C++98
0 / 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[i], a[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...