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>
int ps[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
int pn=15;
int n;
int data[2223];
int mask[2223];
int dp[1<<15];
int overcnt[2223];
int onecnt;
int sqn = 47;
int M=int(1e9)+7;
bool isprime(int x){
for(int i=2;i*i<=x;++i) if(x%i==0) return 0;
return 1;
}
int main()
{
int i,j;
scanf("%d",&n);
for(i=0;i<n;++i){
scanf("%d",data+i);
if(data[i]==1) ++onecnt;
else {
if(data[i]>sqn && isprime(data[i])) ++overcnt[data[i]];
else {
for(j=0; j<pn; ++j){
if(data[i]%ps[j]==0){
mask[i]|=(1<<j);
}
}
}
}
}
dp[0]=1;
for(i=0;i<n;++i){
if(data[i]==1 || overcnt[data[i]]) continue;
int cm=mask[i];
for(j=0;j<32768;++j){
if((j&cm)==cm){
dp[j]+=dp[j^cm];
dp[j]%=M;
}
}
}
int asdf=1;
for(i=sqn+1;i<=2222;++i){
if(overcnt[i]){
asdf=(asdf*1LL*(overcnt[i]+1))%M;
}
}
for(;onecnt--;) asdf=(asdf*2)%M;
int fdsa=0;
for(i=0;i<32768;++i){
//if(dp[i]) printf("Mask %d : %d\n",i,dp[i]);
fdsa=(fdsa+dp[i])%M;
}
printf("%d\n",int((asdf*1LL*fdsa%M-n-1+M)%M));
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... |