fork download
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. long int sum(long int n)
  5. {
  6. long int sum=0;
  7. while(n>0)
  8. {
  9. sum+=(n%10);
  10. n=n/10;
  11. }
  12. return sum;
  13. }
  14. int main() {
  15. // your code goes here
  16. int t;
  17. cin>>t;
  18. if(t>=1&&t<=10000)
  19. {
  20. while(t--)
  21. {
  22. long int n,no;
  23. cin>>n;
  24. if(n>=1&&n<=pow(10,18))
  25. {
  26. no=n;
  27. while(no%sum(no))
  28. {
  29. no++;
  30. }
  31. cout<<no<<'\n';
  32. }
  33.  
  34. }
  35. }
  36. return 0;
  37. }
Success #stdin #stdout 0s 15232KB
stdin
20
555555555555555555
555555555555555555
555555555555555555
555555555555555555
555555555555555555
555555555555555555
555555555555555555
555555555555555555
555555555555555555
555555555555555555
555555555555555555
555555555555555555
555555555555555555
555555555555555555
555555555555555555
555555555555555555
555555555555555555
555555555555555555
555555555555555555
555555555555555555
stdout
555555555555555558
555555555555555558
555555555555555558
555555555555555558
555555555555555558
555555555555555558
555555555555555558
555555555555555558
555555555555555558
555555555555555558
555555555555555558
555555555555555558
555555555555555558
555555555555555558
555555555555555558
555555555555555558
555555555555555558
555555555555555558
555555555555555558
555555555555555558