Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- void print_string(string &cur_string, int bits_count, const int k, vector<char> &alf) {
- if (bits_count == 0) {
- cout << cur_string << '\n';
- return;
- }
- for (int i = k - 1; i >= 0; --i) {
- cur_string.push_back(alf[i]);
- print_string(cur_string, bits_count - 1, k, alf);
- cur_string.pop_back();
- }
- }
- int main() {
- int n, k;
- cin >> n >> k;
- vector<char> alf = {};
- for (int i = 0; i < min(k, 10); ++i) {
- alf.push_back('0' + i);
- }
- for (int i = 0; i < k - 10; ++i){
- alf.push_back('a' + i);
- }
- string s;
- print_string(s, n, k, alf);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement