-
Notifications
You must be signed in to change notification settings - Fork 0
/
problem 4.cpp
82 lines (63 loc) · 1.49 KB
/
problem 4.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mod 1000000007
#define for1(k,n) for(ll i=k;i<n;i++)
#define for2(k,n) for(ll j=k;j<n;j++)
#define E cout<<endl
#define max 100000
#define matrix vector <vector <ll>>
int checkPallindrome(ll n)
{
std::vector<int> v;
while (n != 0)
{
int a;
a = n % 10;
n = n / 10;
v.pb(a);
}
for (int i = 0; i < v.size(); i++)
{
if (v[i] != v[v.size() - 1 - i])
{
return 0;
}
}
return 1;
}
int main()
{
ios_base:: sync_with_stdio(false);
cin.tie(0);
//////////////////////////////////////start...............
cout<<"Enter value of n which is less than or equal to 3-4"<<endl;
ll n;
cin >> n; // when n = 3;
ll large = 1;
ll a = pow(10, n ) / 10;
ll b = pow(10, n ) / 10;
cout << a << " " << b << endl;
for1(a, (a*10)-1)
{
for2(100, (b*10)-1)
{ int flag = 0;
ll pro = i * j;
flag = checkPallindrome(pro);
if (flag == 1 && large < pro)
large = pro;
}
}
cout << large << endl;
/////////////////////////////end................................... ....
cout << "\nDone in " << (double) clock() / CLOCKS_PER_SEC << "sec" << endl;
return 0;
}
//c v a s selecting text or x for selecting cut
//ctrl+d after selecting text to select same type
//ctrl+shift+d for copy and paste the line below it
//ctrl+del to delete a text
//ctrl+left to jump left of line or vice versa
//ctrl+shift+"/" to comment whole block and vice versa for undo
//ctrl+"/" for commenting a line