fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void solve() {
  5. long long n;
  6. cin >> n;
  7. vector<long long> ans;
  8.  
  9. for (int k = 1; k <= 18; k++) {
  10. long long d = 1;
  11. for (int i = 0; i < k; i++) d *= 10;
  12. d += 1;
  13. if (n % d == 0) ans.push_back(n / d);
  14. }
  15.  
  16. if (ans.empty()) cout << 0 << "\n";
  17. else {
  18. cout << ans.size() << "\n";
  19. for (auto x : ans) cout << x << " ";
  20. cout << "\n";
  21. }
  22. }
  23.  
  24. int main() {
  25. ios::sync_with_stdio(false);
  26. cin.tie(0);
  27.  
  28. int t;
  29. cin >> t;
  30. while (t--) solve();
  31. }
Success #stdin #stdout 0.01s 5288KB
stdin
5
1111
12
55
999999999999999999
1000000000000000000
stdout
2
101 11 
0
1
5 
3
90909090909090909 999000999000999 999999999 
0