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