image 

 

 

题解

莫比乌斯反演(可我式子都没列出来。。。直接写了个n^4+剪枝没想到有65分)

我推出来的式子不太一样,但时间复杂度使一样的。。。

代码:

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define N 100005
const int mod=323232323;
int gcd(int x,int y){return !y?x:gcd(y,x%y);}
int fac[N],inv[N],prime[N],mu[N],tot;
bool vis[N];
void shai()
{
	int n=100000,i,j;
	vis[1]=1;mu[1]=1;
	for(i=2;i<=n;i++){
		if(!vis[i]){
			prime[++tot]=i;
			mu[i]=mod-1;
		}
		for(j=1;j<=tot;j++){
			int tmp=i*prime[j];
			if(tmp>n)break;
			vis[tmp]=1;
			if(i%prime[j]==0){mu[tmp]=0;break;}
			mu[tmp]=mod-mu[i];
		}
	}
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for(i=2;i<=n;i++){
		fac[i]=1ll*fac[i-1]*i%mod;
		inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	}
	for(i=2;i<=n;i++)
		inv[i]=1ll*inv[i-1]*inv[i]%mod;
}
int C(int x,int y)
{
	if(y<0||x<y)return 0;
	return 1ll*fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int F1(int x)
{
	return 1ll*x*(x+1)/2%mod;
}
int main()
{
	freopen("a.in","r",stdin);
	freopen("a.out","w",stdout);
	int n,m,K,d,g;
	int ans=0;shai();
	scanf("%d%d%d",&n,&m,&K);
	if(K==1){printf("%d",int(1ll*n*m%mod));return 0;}
	for(g=1;g<=min(n,m);g++){
		int sum=0,lim=min(n/g,m/g);
		for(d=1;d<=lim;d++)
			sum=(sum+1ll*mu[d]*(1ll*(n/(d*g))*n%mod+1ll*mod-1ll*d*g*F1(n/(d*g))%mod)%mod
							  *(1ll*(m/(d*g))*m%mod+1ll*mod-1ll*d*g*F1(m/(d*g))%mod)%mod)%mod;
		ans=(1ll*ans+1ll*C(g-1,K-2)*sum)%mod;
	}
	ans=2ll*ans%mod;
	ans=(ans+1ll*C(n,K)*m%mod+1ll*C(m,K)*n%mod)%mod;
	printf("%d",ans);
}

 

 

 

 

 

image 

题解

 

代码:还没写

 

 

image 

题解

代码:

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
inline int gi()
{
	char c;int num=0,flg=1;
	while((c=getchar())<'0'||c>'9')if(c=='-')flg=-1;
	while(c>='0'&&c<='9'){num=num*10+c-48;c=getchar();}
	return num*flg;
}
#define N 10005
const int mod=323232323;
int n,a[N],fa[N],siz[N],sum[N],f[N][N];
int main()
{
	freopen("c.in","r",stdin);
	freopen("c.out","w",stdout);
	int i,j,k,x,y;
	n=gi();
	for(i=1;i<=n;i++){
		a[i]=gi()+i-1;
		if(a[i]>n){printf("0\n");return 0;}
	}
	a[1]=n;
	for(i=n;i>=1;i--){
		fa[i]=i;siz[i]=1;
		a[i]=a[fa[a[i]]];
		f[i][siz[i]]=1;
		for(j=i+1;j<=a[i];j=a[j]+1){
			sum[siz[i]+1]=0;
			for(k=siz[i];k>=1;k--){
				sum[k]=(sum[k+1]+f[i][k])%mod;
				f[i][k]=0;
			}
			for(x=1;x<=siz[i];x++)
				for(y=1;y<=siz[j];y++)
					f[i][x+y]=(1ll*f[i][x+y]+1ll*sum[x]*f[j][y])%mod;
			siz[i]+=siz[j];
		}
		for(j=i+1;j<=a[i];j++) fa[j]=i;
	}
	int ans=0;
	for(i=1;i<=n;i++)ans=(ans+f[1][i])%mod;
	printf("%d\n",ans);
}