-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem38.cpp
More file actions
54 lines (51 loc) · 1.87 KB
/
Problem38.cpp
File metadata and controls
54 lines (51 loc) · 1.87 KB
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
48
49
50
51
52
53
54
/*
Krishna Mohan
Project Euler - Problem 38
Date: 3/22/2015
*/
#include <bits/stdc++.h>
using namespace std;
#define fo(i, n) for(int (i)=0;(i)<(n); (i)++)
#define MAX 100001
int main() {
int num, len, m[10], f;
string str="", max="";
for(int i=1;i<MAX;i++)
{
memset(m, 0, sizeof(m));
len=0;
str="";
for(int j=1;j<10;j++)
{
num=i*j;
ostringstream ss;
ss<<num;
str+=ss.str();
while(num)
{
m[num%10]++;
num/=10;
len++;
}
if(len>=9)
break;
}
if(len>9)
continue;
else
{
f=0;
for(int k=1;k<10;k++)
{
if(m[k]!=1)
{
f=1;
break;
}
}
if(!f)
cout<<i<<" -> "<<str<<endl;
}
}
return 0;
}