-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem 4.cpp
More file actions
58 lines (54 loc) · 1.01 KB
/
problem 4.cpp
File metadata and controls
58 lines (54 loc) · 1.01 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
55
56
57
58
//ANSWER IS 906609
//EXECUTION PROCESS TAKES 10.425 SECONDS.
#include<iostream>
using namespace std;
int pall(long a)
{
long z=0,r=a;
do
{
int x=a%10;
z=z*10 + x;
a=a/10;
}while(a>0);
// cout<<z<<" "<<r<<"\n";
if(z==r)
return 1;
else
return 0;
}
int digit(int a)
{
int x=0;
while(a>0)
{
x++;
a/=10;
}
return x;
}
int main()
{
long num=1000000;
int flag=1;
while(flag==1)
{
num--;
cout<<num<<"\n";
if(pall(num)==1)
{
long a=100;
while(a<1000)
{
if(num%a==0&&digit(num/a)==3&&a<1000)
{
cout<<a<<" "<<num/a<<"\n";
flag=0;
break;
}
a++;
}
}
}
cout<<num;
}