fork download
  1. /* AUTHOR: TUAN ANH - BUI */
  2. // ~~ icebear ~~
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5. #define int long long
  6. typedef long long ll;
  7. typedef pair<int, int> ii;
  8. typedef pair<int, ii> iii;
  9.  
  10. template<class X, class Y>
  11. bool minimize(X &x, const Y &y) {
  12. if (x > y) return x = y, true;
  13. return false;
  14. }
  15.  
  16. template<class X, class Y>
  17. bool maximize(X &x, const Y &y) {
  18. if (x < y) return x = y, true;
  19. return false;
  20. }
  21.  
  22. #define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
  23. #define FORR(i,a,b) for(int i=(a); i>=(b); --i)
  24. #define REP(i, n) for(int i=0; i<(n); ++i)
  25. #define RED(i, n) for(int i=(n)-1; i>=0; --i)
  26. #define MASK(i) (1LL << (i))
  27. #define BIT(S, i) (((S) >> (i)) & 1)
  28. #define mp make_pair
  29. #define pb push_back
  30. #define fi first
  31. #define se second
  32. #define all(x) x.begin(), x.end()
  33. #define task "icebear"
  34. /*END OF TEMPLATE. ICEBEAR AND THE CAT WILL WIN VOI26 */
  35.  
  36. const int MOD = 1e3 + 7;
  37. const int inf = (int)1e9 + 27092008;
  38. const ll INF = (ll)1e18 + 27092008;
  39. const int N = 2e5 + 5;
  40. int n, q, node[N << 2], lazy[N << 2];
  41. int fibo[N], a[N];
  42.  
  43. void init(void) {
  44. cin >> n >> q;
  45. fibo[1] = fibo[2] = 1;
  46. FOR(i, 3, N - 5) fibo[i] = (fibo[i - 1] + fibo[i - 2]) % MOD;
  47. }
  48.  
  49. void process(void) {
  50. while(q--) {
  51. int t;
  52. cin >> t;
  53. if (t == 1) {
  54. int l,r , k;
  55. cin >> l >> r >> k;
  56. assert(k < N);
  57. FOR(i, l, r) a[i] += fibo[k];
  58. } else {
  59. int l, r;
  60. cin >> l >> r;
  61. int ans = 0;
  62. FOR(i, l, r) ans += a[i];
  63. cout << ans << '\n';
  64. }
  65. }
  66. }
  67.  
  68. signed main() {
  69. ios_base::sync_with_stdio(0);
  70. cin.tie(0); cout.tie(0);
  71. if (fopen(task".inp", "r")) {
  72. freopen(task".inp", "r", stdin);
  73. freopen(task".out", "w", stdout);
  74. }
  75. int tc = 1;
  76. // cin >> tc;
  77. while(tc--) {
  78. init();
  79. process();
  80. }
  81. return 0;
  82. }
  83.  
Success #stdin #stdout 0.01s 7736KB
stdin
Standard input is empty
stdout
Standard output is empty