蒟蒻WA穿含泪求助大佬qwq
查看原帖
蒟蒻WA穿含泪求助大佬qwq
125355
Mihari楼主2020/5/29 10:58

RT,蒟蒻的代码布吉岛什么原因,只有 10pts10pts 过不了,求助各位 AK 大佬。

#include<bits/stdc++.h>
using namespace std;

#define rep(i,__l,__r) for(signed i=(__l),i##_end_=(__r);i<=i##_end_;++i)
#define fep(i,__l,__r) for(signed i=(__l),i##_end_=(__r);i>=i##_end_;--i)
#define writc(a,b) fwrit(a),putchar(b)
#define mp(a,b) make_pair(a,b)
#define ft first
#define sd second
#define LL long long
#define ull unsigned long long
#define uint unsigned int
#define pii pair< int,int >
#define Endl putchar('\n')
// #define int long long
#define int unsigned
// #define int unsigned long long

#ifdef _GLIBCXX_CSTDIO
#define cg (c=getchar())
template<class T>inline void qread(T& x){
    char c;bool f=0;
    while(cg<'0'||'9'<c)f|=(c=='-');
    for(x=(c^48);'0'<=cg&&c<='9';x=(x<<1)+(x<<3)+(c^48));
    if(f)x=-x;
}
template<class T>inline T qread(const T sample){
    T x=0;char c;bool f=0;
    while(cg<'0'||'9'<c)f|=(c=='-');
    for(x=(c^48);'0'<=cg&&c<='9';x=(x<<1)+(x<<3)+(c^48));
    return f?-x:x;
}
#undef cg
template<class T>void fwrit(const T x){//just short,int and long long
    if(x<0)return (void)(putchar('-'),fwrit(-x));
    if(x>9)fwrit(x/10);
    putchar(x%10^48);
}
#endif
// template<class T,class... Args>inline void qread(T& x,Args&... args){qread(x),qread(args...);}
template<class T>inline T Max(const T x,const T y){return x>y?x:y;}
template<class T>inline T Min(const T x,const T y){return x<y?x:y;}
template<class T>inline T fab(const T x){return x>0?x:-x;}
inline int gcd(const int a,const int b){return b?gcd(b,a%b):a;}
inline void getInv(int inv[],const int lim,const int MOD){
    inv[0]=inv[1]=1;for(int i=2;i<=lim;++i)inv[i]=1ll*inv[MOD%i]*(MOD-MOD/i)%MOD;
}
inline LL mulMod(const LL a,const LL b,const LL mod){//long long multiplie_mod
    return ((a*b-(LL)((long double)a/mod*b+1e-8)*mod)%mod+mod)%mod;
}

const int jzm=1e9+7;
const int MAXN=1e6;
const int MAXA=2e5;

int a[MAXN+5],t[MAXA+5],n,maxx;

inline void Init(){
    n=qread(1);
    rep(i,1,n)maxx=Max(a[i]=qread(1),maxx);
}

inline void Gethas(){
    sort(a+1,a+1+n);
    int p1,p2,p3;
    p1=p2=p3=1;
    while(p3<=n){
        while(p3<=n && a[++p3]==a[p2]);
        t[a[p1++]=a[p2]]=p3-p2;
        if(a[p2]==0)--p1;
        p2=p3;
    }n=p1-1;
    // printf("%d %d\n",0,t[0]);
    // rep(i,1,n)printf("%d %d\n",a[i],t[a[i]]);
}

int phi[MAXA<<1|2],prime[MAXA+5],pcnt;
inline void sieve(const int lim){
    phi[1]=1;
    rep(i,2,lim){
        if(!phi[i])prime[++pcnt]=i,phi[i]=i-1;
        for(int j=1;j<=pcnt && i*prime[j]<=lim;++j){
            if(i%prime[j]==0){
                phi[i*prime[j]]=phi[i]*prime[j];
                break;
            }phi[i*prime[j]]=phi[i]*(prime[j]-1);
        }
    }
}

inline int qkpow(int a,int n){
    int ret=1;
    for(;n>0;n>>=1){
        if(n&1)ret=1ll*ret*a%jzm;
        a=1ll*a*a%jzm;
    }return ret;
}

int dp[MAXA<<1|2],ans;

signed main(){
    // ios::sync_with_stdio(false);
    Init();
    Gethas();
    sieve(MAXA<<1);
    int wtf=1;
    while(wtf<=maxx)wtf<<=1;--wtf;
    rep(i,1,n)dp[a[i]]=t[a[i]];
    ans=dp[0]=qkpow(2,t[0]);
    rep(i,1,wtf){
        for(int j=(i-1)&i;j>i-j;j=(j-1)&i)
            dp[i]=(0ll+dp[i]+t[j]*dp[i-j]%jzm)%jzm;
        ans=(0ll+ans+1ll*dp[i]*dp[0]%jzm*phi[i+1]%jzm)%jzm;
    }writc(ans,'\n');
	return 0;
}
/*
testData:
10
4 56 6 1 4 625 20 0 0 3 7
*/
2020/5/29 10:58
加载中...