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