源码:毫无Latex
垃圾题目,卡常
使用Pollard-rho,把所有质数与指数算出来,思维难度:xxs
卡常难度:WC2017挑战(误
从网上贺来了各种最快的板子,拼凑起来极草
优化小妙招:[更快地分解质因数](https://www.luogu.com.cn/blog/Peterprpr/sp30755)
丑代码:
```cpp
#include<bits/stdc++.h>
using namespace std;
namespace Fastio {
struct Reader {
template<typename T>
Reader& operator >> (T& x) {
char c = getchar();
T f = 1;
while (c < '0' || c > '9') {
if (c == '-') f = -1;
c = getchar();
}
x = 0;
while (c >= '0' && c <= '9') {
x = x * 10 + (c - '0');
c = getchar();
}
x *= f;
return *this;
}
Reader& operator >> (char& c) {
c = getchar();
while (c == '\n' || c == ' ') c = getchar();
return *this;
}
Reader& operator >> (char* str) {
int len = 0;
char c = getchar();
while (c == '\n' || c == ' ') c = getchar();
while (c != '\n' && c != ' ') {
str[len++] = c;
c = getchar();
}
str[len] = '\0';
return *this;
}
Reader(){}
} cin;
const char endl = '\n';
struct Writer {
template<typename T>
Writer& operator << (T x) {
if (x == 0) { putchar('0'); return *this; }
if (x < 0) { putchar('-'); x = -x; }
static int sta[45];
int top = 0;
while (x) { sta[++top] = x % 10; x /= 10; }
while (top) { putchar(sta[top] + '0'); --top; }
return *this;
}
Writer& operator << (char c) {
putchar(c);
return *this;
}
Writer& operator << (char* str) {
int cur = 0;
while (str[cur]) putchar(str[cur++]);
return *this;
}
Writer& operator << (const char* str) {
int cur = 0;
while (str[cur]) putchar(str[cur++]);
return *this;
}
Writer(){}
} cout;
} // namespace Fastio
#define cin Fastio :: cin
#define cout Fastio :: cout
#define endl Fastio :: endl
/* --------------- fast io --------------- */ // end
#define int long long
#define maxn 1000010
long long gcd(long long a, long long b) {
int ret = 0;
while(a) {
for( ; !(a & 1) && !(b & 1); ++ret, a >>= 1, b >>= 1);
for( ; !(a & 1); a >>= 1);
for( ; !(b & 1); b >>= 1);
if(a < b) swap(a, b);
a -= b;
}
return b << ret;
}
inline long long mod_add(long long x, long long y, long long m){
return (x += y) < m ? x : x - m;
}
inline long long ksc(long long x, long long y, long long m){
long long res = x * y - (long long)((long double)x * y / m + 0.5) * m;
return res < 0 ? res + m : res;
}
int Abs(int a){
if(a>=0)return a;
return -a;
}
int ksm(int a,int b,int p){
int ans=1;
for(;b;b>>=1,a=ksc(a,a,p))
if(b&1)ans=ksc(ans,a,p);
return ans;
}
signed pri[maxn],lpf[maxn],tot;
void shai(int n){
for(int i=2;i<=n;i++){
if(!lpf[i])pri[lpf[i]=++tot]=i;
for(int j=1;j<=lpf[i]&&i*pri[j]<=n;j++)lpf[i*pri[j]]=j;
}
}
const int p[] = {2, 3, 5, 7, 17, 19, 61};
bool MR(int n) {
if(n<=1000000)return pri[lpf[n]]==n;
if (n == 1)
return 0;
int i;
for (i = 0; i < 7; ++i)
if (!(n % p[i]))
return n == p[i];
int r = n - 1, x, y;
int j, t = 0;
while (!(r & 1))
r >>= 1, ++t;
for (i = 2; i < 7; ++i) {
for (j = 0, y = ksm(p[i], r, n); j < t && y > 1; ++j)
x = y, y = (__int128)x * x % n;
if (y > 1 || (j && x != n - 1))
return 0;
}
return 1;
}
int f(int x,int c,int n){
return ((__int128)x*x+c)%n;
}
long long seq[maxn];
long long PR(long long n){
while (1){
long long x = rand() % n, y = x, c = rand() % n, u = 1, v, t = 0;
long long *px = seq, *py = seq;
while (1){
*py++ = y = mod_add(ksc(y, y, n), c, n);
*py++ = y = mod_add(ksc(y, y, n), c, n);
if((x = *px++) == y) break;
v = u;
u = ksc(u, abs(y - x), n);
if (!u) return gcd(v, n);
if (++t == 32){
t = 0;
if ((u = gcd(u, n)) > 1 && u < n) return u;
}
}
if (t && (u = gcd(u, n)) > 1 && u < n) return u;
}
}
signed n;
int x;
long long ans=1;
const int P=998244353;
unordered_map<int,int>M;
vector<int>G;
vector<int>fac(int x){
vector<int>v,w;
if(x<=1000000){
while(x-1)v.push_back(pri[lpf[x]]),x/=pri[lpf[x]];
return v;
}
if(MR(x))return vector<int>{x};
int p=x;
while(p==x)p=PR(x);
v=fac(p),w=fac(x/p);
v.insert(v.end(),w.begin(),w.end());
sort(v.begin(),v.end());
return v;
}
signed main(){
cin>>n;
shai(1000000);
for(int i=1;i<=n;i++){
cin>>x,G=fac(x);
for(auto j:G)M[j]++;
}
for(auto it:M)
ans=ans*(it.second+1)%P;
cout<<ans;
}
但是