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 data[2240];
int map1[2240][2240];
int now,n;
int ndata[2240];
int tot=0;
int check[2240];
void aa(int cnt,int la)
{
int i,j;
if(cnt==now)
{
for(i=0; i<cnt; i++)
{
for(j=i; j<cnt; j++)
{
if(i==j) continue;
if(map1[ndata[i]][ndata[j]]!=1) return;
}
}
tot++;
return;
}
for(i=la; i<=n; i++)
{
if(check[i]==0)
{
check[i]=1;
ndata[cnt]=i;
aa(cnt+1,i);
check[i]=0;
}
}
}
int main()
{
int i,j,a,b,cc=0,dump=0;
scanf("%d\n",&n);
for(i=1; i<=n; i++)
{
scanf("%d ",&data[i]);
}
/** 유클리드 시작 **/
for(i=1; i<=n; i++)
{
for(j=i; j<=n; j++)
{
if(i==j) continue;
cc=0;
a=data[i];
b=data[j];
do
{
if(b>a)
{
dump=a;
a=b;
b=dump;
}
if(b==0)
{
if(a==1) cc=1;
else cc=0;
break;
}
a%=b;
}
while(1);
if(cc==1)
{
map1[i][j]=1;
}
}
}
/** 유클리드 끝 **/
for(i=2; i<=n; i++)
{
now=i;
aa(0,1);
}
printf("%d",tot);
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... |