59pts,WA + RE 球球大佬帮调qwq
  • 板块P9836 种树
  • 楼主TLE_
  • 当前回复0
  • 已保存回复0
  • 发布时间2023/11/13 10:10
  • 上次更新2023/11/18 17:00:25
查看原帖
59pts,WA + RE 球球大佬帮调qwq
393076
TLE_楼主2023/11/13 10:10

提交记录

#include<bits/stdc++.h>
#define int long long
#define mod 998244353
using namespace std;
int p[1000010];
int buc[1000010];
priority_queue<int>q[1000010];
void pre(int x){
	int sx = sqrt(x);
	sx++;
	for(int i = 2;i <= sx;i++){
		bool ck = 0;
		int aa = 0;
		while(x % i == 0){
			ck = 1;
			aa++;
			x /= i;
		}
		q[i].push(0 - aa);
	}
	if(x > 1)q[x].push(0 - 1);
}
void pre2(int x){
	int sx = sqrt(x);
	sx++;
	for(int i = 2;i <= sx;i++){
		int aa = 0;
		while(x % i == 0){
			aa++;
			x /= i;
		}
		buc[i] = aa;
	}
	if(x > 1)buc[x]++;

}
signed main(){
	int n,w;
	cin >> n >> w;
	for(int i = 1;i <= n;i++){
		cin >> p[i];
		pre(p[i]);
	}	
	pre2(w);
	for(int i = 1;i <= 10001;i++){
		while(buc[i]){
			buc[i]--;
			int qq = q[i].top();
			qq--;
			q[i].pop();
			q[i].push(qq);
		}
	}
	int ans = 1;
	for(int i = 1;i <= 10001;i++){
		while(!q[i].empty()){
			ans *= (0 - q[i].top() + 1);
			ans %= mod;
			q[i].pop();
		}
	}
	cout << ans;
	return 0;
}
2023/11/13 10:10
加载中...