fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. void analyze_digits(long long n, int &min_d, int &max_d, int &count_odd, int &count_even) {
  7. min_d = 9;
  8. max_d = 0;
  9. count_odd = 0;
  10. count_even = 0;
  11.  
  12. while (n > 0) {
  13. int d = n % 10;
  14. min_d = min(min_d, d);
  15. max_d = max(max_d, d);
  16.  
  17. if (d % 2 == 0) {
  18. count_even++;
  19. } else {
  20. count_odd++;
  21. }
  22.  
  23. n /= 10;
  24. }
  25. }
  26.  
  27. void solve() {
  28. long long n;
  29. cin >> n;
  30.  
  31. int min_d, max_d, count_odd, count_even;
  32. analyze_digits(n, min_d, max_d, count_odd, count_even);
  33.  
  34. if ((max_d - min_d) % 2 == 0 && count_odd == count_even) {
  35. cout << "YASS " << min_d << " " << max_d << " " << count_odd << " " << count_even << "\n";
  36. } else {
  37. cout << "NO\n";
  38. }
  39. }
  40.  
  41. int main() {
  42. ios_base::sync_with_stdio(false);
  43. cin.tie(NULL);
  44.  
  45. int t;
  46. if (cin >> t) {
  47. while (t--) {
  48. solve();
  49. }
  50. }
  51.  
  52. return 0;
  53. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty