-
Notifications
You must be signed in to change notification settings - Fork 10
/
pe038.cpp
47 lines (44 loc) · 917 Bytes
/
pe038.cpp
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// by Lashuk
// This is my solution in C++
#include <cstdio>
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
int pan(int n, int k){
int digs[10] = {0};
int filled = 0;
for(int i=1;;i++){
int num = n*i;
while(num != 0){
int d = num%10;
if(d == 0 || (d== 9 && k == 8)) return false;
num /= 10;
if(digs[d] == 1){
return false;
}else{
digs[d] = 1;
filled++;
}
}
if(filled == k){
return true;
}
}
}
int main(){
int n, k; scanf("%d %d", &n, &k);
for(int i=2;i<n;i++){
if(pan(i, k)){
printf("%d\n", i);
}
}
}