50pts 一半AC一半RE
  • 板块P9836 种树
  • 楼主steveyang137
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/11/13 22:13
  • 上次更新2023/11/14 10:40:25
查看原帖
50pts 一半AC一半RE
228625
steveyang137楼主2023/11/13 22:13
#include<cstdio>
using namespace std;
#define MODN 998244353
#define L 1229

int prime[L]=  // 打表素数
int n,w;
long long count[L][100005]={0};

void init();

signed main() {
	init();
	//cout<<3<<endl;
	unsigned long long ans=1;
	int minn;
	for(int i=0;i<L;i++) {
		while(count[i][0]--) {
			minn=0;
			for(int j=1;j<=n;j++) {
				if(count[i][j]==0) {
					minn=j;
					break;
				}
				if(minn==0) minn=j;
				else if(count[i][minn]>count[i][j]) minn=j;
			}
			count[i][minn]++;
			//cout<<prime[i]<<","<<minn<<","<<count[i][minn]<<endl;
		}
	}
	for(int i=1;i<=n;i++) {
		for(int j=0;j<L;j++) {
			if(count[j][i]) ans=ans*(count[j][i]+1)%MODN;
		}
	}
	printf("%u\n",ans);
	
	return 0;
}

void init() {
	scanf("%u %u",&n,&w);
	int p,tp;
	//cout<<1<<endl;
	for(int i=1;i<=n;i++) {
		scanf("%d",&p);
		for(int j=0;prime[j]<=p;j++) {
			if(p%prime[j]==0) {
				tp=p;
				while(tp%prime[j]==0) {
					tp/=prime[j];
					count[j][i]++;
				}
			}
		}
	}
	//cout<<2<<endl;
	if(w<=1) return;
	for(int i=0;prime[i]<=w;i++) {
		if(w%prime[i]==0) {
			tp=w;
			while(tp%prime[i]==0) {
				tp/=prime[i];
				count[i][0]++;
			}
		}
	}
	return;
}
2023/11/13 22:13
加载中...