Advertisement
sherry_ahmos

Untitled

Dec 4th, 2022
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>
  4. #include <bits/stdc++.h>
  5.  
  6. using namespace std;
  7.  
  8. #define ll long long
  9. #define cy cout << "YES"
  10. #define cn cout << "NO"
  11. #define nl "\n"
  12. #define fi first
  13. #define se second
  14. #define MOD 1000000007
  15. #define all(v) v.begin(), v.end()
  16. #define sz(s) s.size()
  17. #define f0r(i, n) for (ll i = 0; i < n; i++)
  18. template <typename T = int>
  19. istream &operator>>(istream &in, vector<T> &v)
  20. {
  21.     for (auto &x : v)
  22.         in >> x;
  23.     return in;
  24. }
  25.  
  26. template <typename T = int>
  27. ostream &operator<<(ostream &out, const vector<T> &v)
  28. {
  29.     for (const T &x : v)
  30.         out << x << " ";
  31.     return out;
  32. }
  33.  
  34. void sherry()
  35. {
  36.     ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  37. #ifndef ONLINE_JUDGE
  38.     freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  39. #endif
  40. }
  41.  
  42. int main()
  43. {
  44.     sherry();
  45.     ll t;
  46.     cin >> t;
  47.     vector<ll> v(1e5 + 5);
  48.     v[1] = 0, v[2] = 1;
  49.     for (int i = 3; i < 1e5 + 5; i++)
  50.     {
  51.         v[i] = v[i - 1] % MOD + v[i - 2] % MOD;
  52.     }
  53.     while (t--)
  54.     {
  55.         ll l, r;
  56.         cin >> l >> r;
  57.         cout << v[r] % MOD - v[l] % MOD << nl;
  58.     }
  59.     return 0;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement