[Offer收割]编程练习赛23 register

Ended

Participants:430

Verdict:Accepted
Score:100 / 100
Submitted:2017-08-20 12:09:08

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
using namespace std;
bool used[10] = { false };
int len;
char s[10];
int n, k;
char result[10] = {0};
void dfs(int t, int loc) {
    result[loc] = t+'0';
    if (loc == n- 1) {
        printf("%s\n", result);
        return;
    }
    for (int i = 0; i <= 9; i++) {
        if (t*i <= k && i <= k)
            dfs(i, loc + 1);
    }
    return;
}
int main() {
    cin >> n >> k;
    for (int i = 1; i <= 9; i++){
        if(i <= k)
        dfs(i, 0);
    }
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX