首页 > TAG信息列表 > 235422

【牛客网235422 区间最大值】题解

题目地址 题目 思路 以下分数皆表示整除 \[\Large\max(n\bmod i)\\\Large=\max(n-\frac n i\times i)\\\Large=n+\max(-\frac n i\times i)\\\Large=n-\min(\frac n i \times i) \]显然,当 \(\frac n i\) 一定时,\(i\) 越小越好,所以可以把每个 \(\frac n i\) 求出来,然后数列分块取