Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main () {
  5. int a [2021];
  6. a[0] = 1;
  7. a[1] = 1;
  8. cout << a[0] << endl;
  9. for (int i = 2; i <= 2019; i++) {
  10. if (i % 2 == 1) {
  11. a[i] = a[(i - 1) / 2] + 1;
  12. } else {
  13. a[i] = a[i / 2];
  14. }
  15. cout << a[i] << " ";
  16. }
  17. int c = 0;
  18. for (int i = 1; i <= 2019; i++) {
  19. c = a[i] == 9 ? c + 1 : c;
  20. }
  21. cout << endl << endl << c;
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement