下面的代码会RE(本地)/TLE(luogu):
ll pollard_rho(ll const x){
if((x&1)==0) return 2LL;
ll c = rand()%(x-1)+1;
static auto f = ([&](ll &t){
t = ((ull)mul(t, t, x) + c) % x;
});
ll t = rand()%(x-1)+1, last = t, sum = 1;
UP(i, 0, 1145) f(t);
for(int goal = 1; goal < (1<<30); goal*=2, last = t, sum = 1){
UP(step, 0, goal){
f(t);
sum = mul(sum, abs(t-last), x);
if(!sum) return x;
if((step & 127) == 0){
ll g = gcd(sum, x);
if(g > 1) return g;
}
}
ll g = gcd(sum, x);
if(g > 1) return g;
}
return x;
}
问题在 f 的定义上,如果换成宏/函数或去掉 static 就能通过
这是为什么?