863A - Quasi-palindrome - CodeForces Solution


brute force implementation *900

Please click on ads to support us..

Python Code:

try  :
    n = int(input())
    a =str(n)
    b = a[::-1]
    count = 0 
    while n % 10 == 0 :
        if n % 10 == 0 :
            count +=1 
            n = n // 10
    if count == 0 :
        if int(b) == n :
            print('Yes')
        else : 
            print('No')
    else :
        b = b + str(count*'0')
        if int(b) == int(a) :
            print('Yes')
        else :
            print('No')
except :
    print('Please enter the correct data type.')

C++ Code:

#include <bits/stdc++.h>

using namespace std;

int main() {
  int n;
  cin >> n;
  string s = to_string(n);
  for (int i = s.size()-1; true ; --i) {
    if(s[i] == '0')
      s.pop_back();
    else               break;
  }
  string rev = s;
  reverse(rev.begin(),rev.end());
  if (rev == s)   cout << "YES";
  else            cout << "NO";
  return 0;
}


Comments

Submit
0 Comments
More Questions

87A - Trains
664A - Complicated GCD
1635D - Infinite Set
1462A - Favorite Sequence
1445B - Elimination
1656C - Make Equal With Mod
567A - Lineland Mail
1553A - Digits Sum
1359B - New Theatre Square
766A - Mahmoud and Longest Uncommon Subsequence
701B - Cells Not Under Attack
702A - Maximum Increase
1656D - K-good
1426A - Floor Number
876A - Trip For Meal
1326B - Maximums
1635C - Differential Sorting
961A - Tetris
1635B - Avoid Local Maximums
20A - BerOS file system
1637A - Sorting Parts
509A - Maximum in Table
1647C - Madoka and Childish Pranks
689B - Mike and Shortcuts
379B - New Year Present
1498A - GCD Sum
1277C - As Simple as One and Two
1301A - Three Strings
460A - Vasya and Socks
1624C - Division by Two and Permutation