//No.701 ひとりしりとり #include #include #include #include using namespace std; string crt_str(char _pre_char); int main() { srand((unsigned int)time(NULL)); int n; cin >> n; if (n == 1)cout << "n"; else cout << "apple" << endl; char pre_char = 'e'; string tmp_str; for (int i = 0; i < n-1; i++) { tmp_str = crt_str(pre_char); pre_char = tmp_str[tmp_str.length() - 1]; if (i == (n - 2))tmp_str += 'n'; else if (tmp_str[tmp_str.length() - 1] == 'n')tmp_str += 'b'; cout << tmp_str << endl; } return 0; } string crt_str(char _pre_char) { //1~20 string str; str += _pre_char; char tmp_char; int ran = rand() % 15 + 4; for (int i = 0; i < 10; i++) { tmp_char = rand() % ('z' - 'a') + 'a'; str += tmp_char; } return str; }