D. Flowers
生活随笔
收集整理的這篇文章主要介紹了
D. Flowers
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
D. Flowers
一個簡單線性dp #include <bits/stdc++.h> using namespace std; #define int long long const int mod = 1e9 + 7; int a[(int)2e6]; signed main() {int t, k;cin >> t >> k;a[0] = 1;for (int i = 1; i <= 1e5 + 5; i++){a[i] = a[i - 1];a[i] %= mod;if (i >= k)a[i] += a[i-k];a[i] %= mod;}for (int i = 1; i <= 1e5; i++){a[i] = (a[i] + a[i - 1]) % mod;}int A, B;while (t--){cin >> A >> B;cout << (a[B] - a[A - 1] + mod) % mod << endl;} }總結
以上是生活随笔為你收集整理的D. Flowers的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: staruml怎么画协作图_er图怎么画
- 下一篇: DOM-8 【兼容】冒泡捕获流、事件与事