fork download
  1. #include<iostream>
  2. #include<cmath>
  3. #include<algorithm>
  4. #include<iomanip>
  5. #include<climits>
  6. #include<numeric>
  7. #include<set>
  8. #include<sstream>
  9. #include<map>
  10. #include<vector>
  11. #include<string>
  12.  
  13. using namespace std;
  14.  
  15. vector<string> split(string haystack, string needle) {
  16. vector<string> result;
  17. int start_pos = 0;
  18. int found_pos = haystack.find(needle, start_pos);
  19. while (found_pos != string::npos) {
  20. int count = found_pos - start_pos;
  21. string token = haystack.substr(start_pos, count);
  22. if (!token.empty()) {
  23. result.push_back(token);
  24. }
  25. start_pos = found_pos + needle.length();
  26. found_pos = haystack.find(needle, start_pos);
  27. }
  28. string token = haystack.substr(start_pos, haystack.length()-start_pos);
  29. if (!token.empty()) {
  30. result.push_back(token);
  31. }
  32. return result;
  33. }
  34. string nameConvert(const string& name) {
  35. const string DELIMITER = " ";
  36. stringstream builder;
  37. auto parts = split(name, DELIMITER);
  38. for (auto part : parts) {
  39. part[0] = toupper(part[0]);
  40. transform(part.begin()+1, part.end(),part.begin()+1, ::tolower);
  41. builder << part << DELIMITER;
  42. }
  43. return builder.str();
  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.  
  56.  
  57. string maxValue(int m, int s) {
  58. string result = "";
  59. while (m--) {
  60. if (s > 9) {
  61. result = result + '9';
  62. s = s - 9;
  63. }
  64. else {
  65. result = result + to_string(s);
  66. s = 0;
  67. }
  68. }
  69. return result;
  70. }
  71.  
  72. string minValue(int m, int s) {
  73. string result = "";
  74. s--;
  75. while (m--) {
  76. if (s > 9) {
  77. result = result + '9';
  78. s = s - 9;
  79. }
  80. else {
  81. result = to_string(s) + result;
  82. s = 0;
  83. }
  84. }
  85. result[0]++;
  86. return result;
  87.  
  88. }
  89. int main() {
  90. int m, s;cin >> m >> s;
  91. if (((m == 1) && (s >9)) || (9*m<s) ) {
  92. cout << "NOT FOUND";
  93.  
  94. }
  95. else if (m == 1 && s == 0) {
  96. cout << 0 << endl << 0;
  97. }
  98. else {
  99. cout << minValue(m, s) << " " << maxValue(m, s);
  100. }
  101. }
  102.  
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
NOT FOUND