fork download
  1. #include<bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4. int s[5];
  5. int xuly(int n)
  6. {
  7. if(n > 18)
  8. return -1;
  9. if(n >= 10)
  10. return (n - 9) * 10 + 9;
  11. else
  12. return n;
  13. }
  14. int main()
  15. {
  16. int n;
  17. cin >> n;
  18. int cnt = 4;
  19. while(n)
  20. {
  21. s[cnt--] = n % 10;
  22. n/=10;
  23. }
  24. int s1 = xuly(s[1] * 10 + s[2]);
  25. int s2 = xuly(s[3] * 10 + s[4]);
  26. if(s1 == -1 || s2 == -1)
  27. {
  28. cout << 0;
  29. return 0;
  30. }
  31. if(s1 > s2) swap(s1, s2);
  32. if(s1 < 10)
  33. {
  34. if(s1 == 0)
  35. {
  36. cout << s2 << "00";
  37. return 0;
  38. }
  39. if(s1 + 9 < s2)
  40. cout << s1 + 9 << s2;
  41. else
  42. cout << s2 << 0 << s1;
  43. }
  44. else
  45. cout << s1 << s2;
  46. }
  47.  
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
Standard output is empty