[题目链接](http://codeforces.com/problemset/problem/474/D)
非常简单的一道dp题,通过O(n)的预处理来使查询变为O(1)。
主要的坑在于取模后的dp数组的前缀和再相减可能得到负数,导致无法得到某一区间和的取模。
解决方法:(a-b)%mo==(a%mo+mo-b%mo)%mo,由于该等式的存在,可以使用取模后的前缀和做运算得到某一区间和的取模。
代码:
```C++
#include
#include
#include
#include
#include
#include
#include
相关文章:
-
2021-11-05
-
2021-12-24
-
2021-09-21
-
2022-01-13
-
2022-12-23
-
2022-12-23
-
2021-10-18
-
2022-01-22
猜你喜欢
-
2021-06-17
-
2021-12-08
-
2022-12-23
-
2021-09-14
-
2022-12-23
-
2022-12-23
-
2021-07-20
相关资源
-
下载
2021-11-02
-
下载
2021-11-03
-
下载
2022-12-18
-
下载
2022-12-05
-
下载
2022-12-29