fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int T, N, count;
  9. vector<int> vec;
  10.  
  11. cin >> T;
  12.  
  13. while(T--)
  14. {
  15. cin >> N;
  16.  
  17. vec.clear();
  18. count = 0;
  19.  
  20. do
  21. {
  22. vec.push_back(N);
  23. N = (N * N / 100) % 10000;
  24.  
  25. count++;
  26. }
  27. while(find(vec.begin(), vec.end(), N) == vec.end());
  28.  
  29. cout << count << " ";
  30. }
  31.  
  32. return 0;
  33. }
Success #stdin #stdout 0s 16064KB
stdin
14
5599 7561 1022 5810 8848 1687 4587 3185 3028 7817 8206 6212 9692 5690
stdout
108 108 100 109 97 107 98 98 108 102 106 101 104 104