fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int x,y;
  7. scanf("%d",&x);
  8. scanf("%d",&y);
  9. int arr[y+1];
  10. arr[1]=1;
  11. for(int i=2;i<=y;i++)
  12. {
  13. int temp=i;
  14. while(1)
  15. {
  16. if(arr[temp]!=0)
  17. {
  18. arr[i]+=arr[temp];
  19. break;
  20. }
  21. else if(temp%2!=0)
  22. {
  23. temp=3*temp+1;
  24. arr[i]++;
  25. }
  26. else
  27. {
  28. temp=temp/2;
  29. arr[i]++;
  30. }
  31. }
  32. }
  33. return 0;
  34. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Standard output is empty