# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
7366 |
2014-08-03T15:08:03 Z |
tncks0121 |
경비원 (GA8_guard) |
C++ |
|
2000 ms |
20444 KB |
#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 time |
Memory |
Grader output |
1 |
Correct |
0 ms |
20444 KB |
Output is correct |
2 |
Correct |
0 ms |
20444 KB |
Output is correct |
3 |
Correct |
0 ms |
20444 KB |
Output is correct |
4 |
Correct |
0 ms |
20444 KB |
Output is correct |
5 |
Incorrect |
0 ms |
20444 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
20444 KB |
Output is correct |
2 |
Correct |
0 ms |
20444 KB |
Output is correct |
3 |
Incorrect |
0 ms |
20444 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2000 ms |
20440 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2000 ms |
20440 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2000 ms |
20440 KB |
Program timed out |
2 |
Halted |
0 ms |
0 KB |
- |