提交时间:2023-05-20 17:23:47
运行 ID: 74189
#include <iostream> using namespace std; int main() { int k; cin >> k; // 最小的数 int min_num = 0; while (k >= 2) { if (k >= 7) { min_num = min_num * 10 + 1; k -= 2; } else if (k >= 2) { min_num = min_num * 10 + 2; k -= 5; } } if (k == 1) { min_num = min_num * 10 + 1; } // 最大的数 int max_num = 0; while (k >= 5) { max_num = max_num * 10 + 2; k -= 5; } while (k >= 2) { max_num = max_num * 10 + 1; k -= 2; } cout << min_num << " " << max_num << endl; return 0; }