-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathB.cpp
52 lines (51 loc) · 838 Bytes
/
B.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
#include <bits/stdc++.h>
using namespace std;
void pal(string n)
{
int afzero=0,bezero=0,result=0;
string h;
for(int i=n.length()-1;i>=0;i--)
{
if(n[i]=='0')
afzero++;
else break;
}
for(int i=0;i<n.length();i++)
{
if(n[i]=='0')
bezero++;
else break;
}
if(afzero>bezero)
{
int zero=afzero-bezero;
for(int i=0;i<zero;i++)
{
h+='0';
}
}
h+=n;
int hsize=h.length();
int j=hsize-1;
for(int i=0;i<=hsize/2;i++)
{
if(j>i)
{
if(h[i]==h[j])
{
result++;
j--;
}
}
}
if(result==hsize/2)
cout<<"Yes\n";
else cout<<"No\n";
}
int main()
{
string x;
cin>>x;
pal(x);
return 0;
}