Submission #7583

# Submission time Handle Problem Language Result Execution time Memory
7583 2014-08-11T13:16:53 Z dohyun0324 경비원 (GA8_guard) C++
0 / 100
0 ms 32768 KB
#include<stdio.h>
long long int d[2510][2510];
int cnt,n,a[2510],m,ch[30],w;
int gcd(int x,int y)
{
    if(x%y==0) return y;
    return gcd(y,x%y);
}
void dfs(int x)
{
    int i;
    if(x==n)
    {
        if(w>=2)
        {
            cnt++;
        }
        return;
    }
    dfs(x+1);
    for(i=1;i<=w;i++)
    {
        if(gcd(ch[i],a[x+1])!=1) break;
    }
    if(i!=w+1) return;
    ch[++w]=a[x+1];
    dfs(x+1);
    ch[w--]=0;
}
int main()
{
    int i,j,s;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        if(m<a[i]) m=a[i];
    }
    //subtask 1
    if(n<=20)
    {
        dfs(1);
        ch[++w]=a[1];
        dfs(1);
        printf("%d",cnt);
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Memory limit exceeded 0 ms 32768 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Memory limit exceeded 0 ms 32768 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Memory limit exceeded 0 ms 32768 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Memory limit exceeded 0 ms 32768 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Memory limit exceeded 0 ms 32768 KB Memory limit exceeded
2 Halted 0 ms 0 KB -