fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int a, b, c, x;
  6. cin >> a >> b >> c >> x;
  7. int a_cnt = 0;
  8. int b_x = x;
  9. int c_copy = x % 10;
  10. while (x > 0) {
  11. if (b_x > 10)
  12. b_x /= 10;
  13. x /= 10;
  14. ++a_cnt;
  15. }
  16. cout << a_cnt << b_x << c_copy;
  17.  
  18. if (c == c_copy && b == b_x && a == a_cnt) {
  19. cout << "DA";
  20. } else {
  21. cout <<"NU";
  22. }
  23. return 0;
  24. }
  25.  
  26. /* Teste:
  27.  
  28. Valori minime
  29.  
  30. 3 1 2 102 -> DA
  31.  
  32. 1 3 2 123 -> NU
  33.  
  34. Valori maxime
  35.  
  36. 9 9 9 900000009 -> DA
  37.  
  38. 9 9 9 90000009 -> NU
  39.  
  40. 9 8 7 987654321 -> NU
  41.  
  42. Numere cu toate cifrele egale
  43.  
  44. 4 4 4 4444 -> DA
  45.  
  46. 7 7 7 7777777 -> DA
  47.  
  48. 8 8 8 888888 -> NU
  49.  
  50. Numere cu toate cifrele distincte
  51.  
  52. 4 4 1 4321 -> DA
  53.  
  54. 7 5 1 7451 -> NU
  55.  
  56.  
  57.  
  58. Numere cu doua cifre identice
  59.  
  60. 4 8 8 8458 -> DA
  61.  
  62. 5 5 6 59796 -> DA
  63.  
  64. Numere cu trei cifre identice
  65.  
  66. 3 3 3 333 -> DA
  67.  
  68. 4 6 8 6888 -> DA */
Success #stdin #stdout 0s 5308KB
stdin
9 9 9 900000009 -> DA
stdout
999DA