noip模拟32[好数学啊] (2)

注意找这个角度的时候,判断是正的还是负的,要不然WA死

AC_code #include<bits/stdc++.h> using namespace std; #define re register int #define ll long long #define pa pair<long long,long long> #define mpa(x,y) make_pair(x,y) #define fi first #define se second const ll mod=1e9+7; ll n; map<pa,ll> mp; ll sum[1<<6],id[1<<6]; pa ys[10]; int top; ll dfs(ll s1,ll s2){ map<pa,ll>::iterator it=mp.find(mpa(s1,s2)); if(it!=mp.end())return it->se; mp.insert(mpa(mpa(s1,s2),1)); it=mp.find(mpa(s1,s2)); for(re i=1;i<(1<<top);i++){ int num=0; bool flag=0; for(re j=1;j<(1<<top);j++){ if(!(i&j))continue; if((s1>>j-1)&1)num++; if((s2>>j-1)&1)flag=1; if(flag||num>=2)break; } if(flag||num>=2)continue; if((s1>>i-1)&1)it->se=(it->se+sum[i]*dfs(s1^(1ll<<i-1),s2|(1ll<<i-1))%mod)%mod; else it->se=(it->se+sum[i]*dfs(s1|(1ll<<i-1),s2)%mod)%mod; } return it->se; } signed main(){ scanf("%lld",&n); for(ll i=2;i*i<=n;i++){ if(n%i)continue; ys[++top].fi=i; while(n%i==0){ ys[top].se++; n/=i; } } if(n!=1)ys[++top].fi=n,ys[top].se=1; for(re i=1;i<=top;i++)id[1<<i-1]=i; sum[0]=1;for(re i=1;i<(1<<top);i++) sum[i]=sum[i^(i&(-i))]*ys[id[i&(-i)]].se%mod; printf("%lld",dfs(0,0)-1); }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zwxyyf.html