4、18

收获:

 1)学会求欧拉函数

 2)有关约数的题目想好是到n还是n/2还是sqrt(n),不然WA和T得飞起

 3)乘法逆元竟然是这个意思

 

疑问:

堆的push_down

我的WA代码

void push_down(int x)
{
    while(x<<1 <=siz)
    {
        int nx=x<<1;
        if(nx<siz && h[nx]<h[nx+1]) nx++;
        if(h[x]<h[nx])
        {
            break;
        }
        heap_swap(x,nx);
        x=nx;
    }
    return ;
}

正确代码:

void push_down(int x)
{
    int t=x;
    if((x<<1) <= siz && h[t]>h[x*2]) t=x<<1;
    if((x<<1)+1 <=siz && h[t]>h[x*2+1]) t=(x<<1)+1;
    if(t!=x)
    {
        heap_swap(x,t);
        push_down(t);
    }
}

没想通为什么我写的过不了

posted @ 2023-04-18 23:51  ddt_cai  阅读(85)  评论(0)    收藏  举报