-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path4.cpp
More file actions
55 lines (44 loc) · 888 Bytes
/
4.cpp
File metadata and controls
55 lines (44 loc) · 888 Bytes
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
#include<iostream>
using namespace std;
bool isPalindrome(int x)
{
if(x/100000==x%10)
{
x=x/10;
if((x/1000)%10==x%10)
{
x=x/10;
if((x/10)%10==x%10)
return true;
}
}
return false;
}
int main()
{
int t,n,flag;
cin>>t;
while(t--)
{
flag=0;
cin>>n;
for(int num=n-1;num>=100000;num--)
{
if(isPalindrome(num))
{
for(int i=143;i<=999;i++)
{
if(num%i==0 && (num/i)/1000==0)
{
cout<<num<<endl;
flag=1;
break;
}
}
}
if(flag==1)
break;
}
}
return 0;
}