include fstream include string include cmath include sstream using nam

 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
#include <fstream>
#include <string>
#include <cmath>
#include <sstream>
using namespace std;
ifstream fin("c.in");
ofstream fout("c.out");
int main()
{
int n,d;
long long s=0,f=0;
string c;
bool ok;
fin>>n>>d;
f=pow(10,n);
if (n==1) s=0; else s=f/10;
if ((n>6)||(n==2)||(n==4)) { s++; f++;} //2 4 7 8
ostringstream convert;
convert << d;
c=convert.str();
for (int i=s;i<f;i++)
{
ostringstream conv;
conv<<i;
string k;
k=conv.str();
ok=true;
if (k.find(c)!=-1) ok=false;
if (ok) fout<<i<<endl;
}
return 0;
}