ProgMe

Untitled

Dec 13th, 2020 (edited)
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. constexpr int mod = 1e9 + 9;
  6.  
  7. int32_t main()
  8. {
  9. int n;
  10. cin >> n;
  11. int cntc [n], cntw [n], cntsp [n], cnti[n];
  12. cntc[0] = 20;
  13. cntsp[0] = 0;
  14. cntw[0] = 10;
  15. cnti[0] = 1;
  16. for(int i = 1; i < n; i++){
  17. cntc[i] = cntw[i - 1] * 20 % mod;
  18. cnti[i] = cntw[i - 1];
  19. cntw[i] = ((cntc[i - 1] * 10) + (cntsp[i - 1] * 10) + cnti[i - 1] * 10) % mod;
  20. cntsp[i] = cntc[i - 1] * 2 % mod;
  21. }
  22. cout << (cntc[n - 1] + cntw[n - 1] + cntsp[n - 1] + cnti[n - 1]) % mod;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment