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