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