Submission #7156

#TimeUsernameProblemLanguageResultExecution timeMemory
7156tncks0121경비원 (GA8_guard)C++98
21 / 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], 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 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...