Submission #7673

#TimeUsernameProblemLanguageResultExecution timeMemory
7673moonrabbit2경비원 (GA8_guard)C++98
0 / 100
468 ms25520 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...