整数分块

计算\(\sum_{n=1}^{n=d} \lfloor \frac{d}{n} \rfloor\),将n分成多个块,

使得每个块\([left<=i<=right], \frac{d}{i}=同一个数\)

struct node
{
    int left,right,num;
};
node a[10000];
int top=0;
for (int l = 1, r; l <= d; l = r + 1)
{
    r = d / (d / l);
    a[++top].left = l, a[top].right = r, a[top].num = x / l;
}


posted on 2022-06-28 00:30  naiji  阅读(26)  评论(0编辑  收藏  举报