Floyd判圈

int k1=k,k2=k;
do
{
    k1=next(n,k1);
    k2=next(n,k2);
    if(k2>ans) ans=k2;
    k2=next(n,k2);
    if(k2>ans) ans=k2;
}while(k1!=k2);

你可能感兴趣的:(Floyd判圈)