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 <cstdio>
#include <algorithm>
#define N 1000000007
using namespace std;
int n;
int a[2500];
int b[2500][2500];
int check[2500];
bool checks=true;
int sum,s,sum2;
int gcd(int a,int b)
{
if(a%b==0)return b;
return gcd(b,a%b);
}
int ncr(int n,int r)
{
int i;
double b=1;
for(i=1;i<=r;i++)
b*=(n-i+1)/(double)i;
return (int)b;
}
int main()
{
int i,j;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
if(check[a[i]])checks=false;
check[a[i]]=1;
}
for(i=0;i<n;i++){
for(j=0;j<n;j++){
if(i==j)continue;
if(gcd(a[i],a[j])!=1){
b[i][j]=1;
s++;
}
}
}
for(i=2;i<=n;i++){
sum+=ncr(n,i);
sum2+=max(ncr(n,i)-(int)s,0);
sum2%=N;
}
if(checks)sum2=max(0,sum2-s);
sum2%=N;
printf("%d",max(sum-s*s,0));
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... |