add: 220322 [cpp]
This commit is contained in:
parent
ab12649430
commit
a8f1083ae7
|
|
@ -0,0 +1,18 @@
|
||||||
|
#include <string>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
class Solution {
|
||||||
|
public:
|
||||||
|
static std::string getSmallestString(int n, int k) {
|
||||||
|
if (n == k)
|
||||||
|
return std::string(n, 'a');
|
||||||
|
if (k - n < 26)
|
||||||
|
return std::string(n - 1, 'a') + static_cast<char>('a' + (k - n));
|
||||||
|
return getSmallestString(n - 1, k - 26) + 'z';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::cout << Solution::getSmallestString(5, 73);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
@ -3,4 +3,4 @@ PROJECT(2203)
|
||||||
|
|
||||||
SET(CMAKE_CXX_STANDARD 23)
|
SET(CMAKE_CXX_STANDARD 23)
|
||||||
|
|
||||||
ADD_EXECUTABLE(2203 220322-CN.cpp)
|
ADD_EXECUTABLE(2203 220322.cpp)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue