-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem04.cpp
More file actions
50 lines (46 loc) · 855 Bytes
/
Copy pathProblem04.cpp
File metadata and controls
50 lines (46 loc) · 855 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
/*
Krishna Mohan
Project Euler - Problem 1
Date: 3/15/2015
*/
#include <bits/stdc++.h>
using namespace std;
#define fo(i, n) for(int (i)=0;(i)<(n); (i)++)
#define foj(i, j, n) for(int (i)=(j);(i)<(n); (i)++)
bool isPalin(int num)
{
char n[100];
int i=0;
while(num)
{
n[i++]=num%10;
num/=10;
}
for(int j=0, k=i-1; j<k; j++, k--)
{
if(n[j]!=n[k])
return false;
}
return true;
}
int main()
{
ios_base::sync_with_stdio(0);
long long ans=0;
foj(i, 900, 1000)
{
foj(j, 900, 1000)
{
cout<<(i*j);
if(isPalin((i*j)))
{
cout<<" -> YES"<<endl;
ans=(i*j);
}
else
cout<<" -> NO"<<endl;
}
}
cout<<ans<<endl;
return 0;
}