GastonFontenla

Untitled

Nov 9th, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define forsn(i, s, n) for(tint i=s;i<tint(n);i++)
  6. #define forn(i, n) forsn(i, 0, n)
  7. #define all(v) v.begin(), v.end()
  8. #define NACHO ios_base::sync_with_stdio(0);cin.tie(NULL);
  9.  
  10. typedef long long tint;
  11.  
  12. const tint MOD = 1000000;
  13.  
  14. int main(){
  15. tint k, d; cin >> k >> d;
  16. queue<tint> q;
  17. tint sum = 1;
  18. ///1 1 2 4 8 16 31
  19. q.push(sum);
  20. forn(i, d-1){
  21. sum = (2*sum) % MOD;
  22. q.push(sum);
  23. if(q.size() > k){
  24. sum = (sum-q.front()+MOD)%MOD;
  25. q.pop();
  26. }
  27. }
  28. cout << sum << endl;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment