Submission #18641

#TimeUsernameProblemLanguageResultExecution timeMemory
18641Namnamseo경비원 (GA8_guard)C++14
40 / 100
226 ms1364 KiB
#include <cstdio> #include <algorithm> #include <queue> 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]; typedef std::pair<int,int> pp; pp dd[2223]; int dp [1<<15]; int dptmp[1<<15]; 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 getMaxDivisor(int x){ for(int i=x;i>=1;--i) if(x%i==0 && isprime(i)) return i; return '?'; } int main() { int i,j; scanf("%d",&n); for(i=0;i<n;++i){ scanf("%d",data+i); dd[i]={getMaxDivisor(data[i]),data[i]}; } std::sort(dd,dd+n); dp[0]=1; dptmp[0]=1; for(i=0;i<n;++i){ int mymask = 0; int myval = dd[i].second; for(j=0; j<pn; ++j) if(myval % ps[j]==0) mymask |= (1<<j); for(j=0; j<32768; ++j){ if((j&mymask) == mymask){ dptmp[j]+=dp[j^mymask]; dptmp[j]%=M; } } if(i+1==n || dd[i].first != dd[i+1].first){ for(j=0; j<32768; ++j) dp[j]=dptmp[j]; } } int ans=0; for(i=0; i<32768; ++i) ans+=dp[i], ans%=M; printf("%d\n",(ans-n-1+M)%M); 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...