fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. ios::sync_with_stdio(false);
  7. cin.tie(0);
  8.  
  9. int t; cin >> t;
  10.  
  11. while (t--) {
  12.  
  13.  
  14.  
  15. long long n; cin >> n;
  16. vector<long long> ans;
  17.  
  18. for (int i = 1; i <= 18; i++) {
  19.  
  20.  
  21. long long d = 1;
  22. for (int j = 0; j < i; j++){
  23. d*=10;
  24. }
  25.  
  26. d+=1; //maybe vul hoitache
  27.  
  28. if (n%d==0) ans.push_back(n/d);
  29. }
  30.  
  31. if (ans.empty()) cout << 0 << "\n";
  32. else {
  33.  
  34. sort(ans.begin(), ans.end()); //acdng er jonne;
  35.  
  36. cout << ans.size() <<"\n";
  37.  
  38. for (auto x : ans) cout << x << " ";
  39. cout << "\n";
  40. }
  41. }
  42. }
  43.  
Success #stdin #stdout 0.01s 5280KB
stdin
5
1111
12
55
999999999999999999
1000000000000000000
stdout
2
11 101 
0
1
5 
3
999999999 999000999000999 90909090909090909 
0