fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <map>
  4. #include <set>
  5. #include <cmath>
  6. #include <vector>
  7. #include <climits>
  8. #include <string>
  9. #include <algorithm>
  10. #include <sstream>
  11. using namespace std;
  12.  
  13. vector<string> split(string haystack, string needle) {
  14. vector<string> result;
  15. int startPos = 0;
  16. int foundPos = haystack.find(needle, startPos);
  17. while (foundPos != string::npos) {
  18. int count = foundPos - startPos;
  19. string token = haystack.substr(startPos, count);
  20. if (!token.empty()) {
  21. result.push_back(token);
  22. }
  23. startPos = foundPos + needle.length();
  24. foundPos = haystack.find(needle, startPos);
  25. }
  26. string token = haystack.substr(startPos, haystack.length() - startPos);
  27. if (!token.empty()) {
  28. result.push_back(token);
  29. }
  30. return result;
  31. }
  32.  
  33. string nameConvert(const string& name) {
  34. const string DELIMITER = " ";
  35. stringstream builder;
  36. auto parts = split(name, DELIMITER);
  37. for (auto part : parts) {
  38. part[0] = toupper(part[0]);
  39. transform(part.begin() + 1, part.end(), part.begin() + 1, ::tolower);
  40. builder << part << DELIMITER;
  41. }
  42. return builder.str();
  43. }
  44.  
  45. string dateConvert(const string& date) {
  46. const string DELIMITER = "/";
  47. stringstream builder;
  48. auto parts = split(date, DELIMITER);
  49. builder << setw(2) << setfill('0') << parts[0] << DELIMITER;
  50. builder << setw(2) << setfill('0') << parts[1] << DELIMITER;
  51. builder << parts[2];
  52. return builder.str();
  53. }
  54.  
  55. bool isPalindrome(string s) {
  56. return equal(s.begin(), s.begin() + s.size() / 2, s.rbegin());
  57. }
  58.  
  59. bool isAtLeastOneDigit(string s, int digit) {
  60. for (auto value : s) {
  61. if ((value - '0') == digit) {
  62. return true;
  63. }
  64. }
  65. return false;
  66. }
  67. int main() {
  68. ios_base::sync_with_stdio(false);
  69. cin.tie(NULL);
  70.  
  71. string n;cin >> n;
  72. if (isPalindrome(n) && isAtLeastOneDigit(n, 6)) {
  73. cout << "YES";
  74. }
  75. else {
  76. cout << "NO";
  77. }
  78. return 0;
  79. }
  80.  
  81.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
NO