P11661 无聊

题目背景

![](https://cdn.luogu.com.cn/upload/image_hosting/f9kqwg7m.png)

题目描述

白很无聊呢,于是她给空出了道题。 给出 $n$ 个数的序列 $a,b$。 求 $b_l\equiv b_r\pmod {\displaystyle\max_{l\le i\le r}a_i}$ 的 $(l,r)$ 个数。

输入格式

输出格式

说明/提示

对于所有测试数据,保证:$1\le n,a_i,b_i\le 5\times10^5$。 | Subtask | $n\le$ | 限制 | 分值 | | :----------: | :----------: | :----------: | :----------: | | $0$ | $10^4$ | - | $5$ | | $1$ | $10^5$ | $a_i\ge a_{i+1}$ | $15$ | | $2$ | $10^5$ | - | $30$ | | $3$ | $5\times10^5$ | - | $50$ |