This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |