250104 力扣
include
include
using namespace std;
string crossConcatenate(const string &a, const string &b) {
string result;
int i = 0;
while (i < a.size() || i < b.size()) {
if (i < a.size()) result += a[i];
if (i < b.size()) result += b[i];
i++;
}
return result;
}
char kthCharacter(int k) {
string word = "a";
while (word.size() < k) {
string next;
for (char c : word) {
next += (c == 'z') ? 'a' : c + 1;
}
word = crossConcatenate(word, next); // 交叉拼接
}
return word[k - 1];
}
int main() {
int k;
cin >> k;
cout << kthCharacter(k) << endl;
return 0;
}
浙公网安备 33010602011771号