fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int TEN = 10;
  5. const int THOUSAND = 1000;
  6. const int TENTHOUSAND = 10000;
  7.  
  8. int main() {
  9. int n;
  10. cin >> n;
  11. int cpyN = n, number = 0;
  12. while (n != 0) {
  13. ++n;
  14. if (cpyN < TEN * TEN) {
  15. if (n % TEN == n / TEN % TEN) {
  16. number = n;
  17. n = 0;
  18. }
  19. }
  20. if (cpyN >= TEN * TEN && cpyN < THOUSAND) {
  21. if (n % TEN == n / TEN % TEN && n / TEN % TEN == n / (TEN * TEN) % TEN) {
  22. number = n;
  23. n = 0;
  24. }
  25. }
  26. if (cpyN >= THOUSAND && cpyN < TENTHOUSAND) {
  27. if (n % TEN == n / TEN % TEN && n / TEN % TEN == n / (TEN * TEN) % TEN && n / (TEN * TEN) % TEN == n / THOUSAND % TEN) {
  28. number = n;
  29. n = 0;
  30. }
  31. }
  32. }
  33. cout << number;
  34. return 0;
  35. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
5555