
ОЧЕНЬ СРОЧНО!!! ДАЮ 100 БАЛЛОВ Дается целое положительное число . Можно ли добавить
несколько(возможно ноль) ведущих нулей, чтобы стало числовым палиндромом? Числовой палиндром — это число, которое читается слева направо и справа налево одинаково. Веду́щие нули́ в записи числа — последовательность из одного или более нулей, стоящие в начале числа. Input Format В первой строке находится одно целое число . Изначально число не содержит ведущих нулей. Constraints Output Format Если можно сделать числовой палиндром, выведите "Yes". Иначе, выведите "No". Sample Input 0 2020 Sample Output 0 Yes

Ответы на вопрос

Ответ:
n = input()
while n[-1] == '0':
if n[-1] == '0':
n = n[:-1]
while n [0] == '0':
if n[0] == '0':
n = n[1:]
if n == n[::-1]:
print('Yes')
else:
print('No')
Объяснение:
знаю, код мамбетский, но работает



To determine if it is possible to add leading zeros to a given positive integer to make it a numerical palindrome, we can follow these steps:
1. Convert the given integer to a string. 2. Check if the string is equal to its reverse. If it is, then it is already a numerical palindrome and we can output "Yes". 3. If the string is not equal to its reverse, we can add leading zeros to the string and check if the modified string is a palindrome. If it is, we can output "Yes". Otherwise, we output "No".
Let's apply these steps to the given sample input of 2020:
1. Convert the integer 2020 to a string: "2020". 2. Check if the string is equal to its reverse: "2020" is not equal to its reverse "0202". 3. Add leading zeros to the string: "02020". 4. Check if the modified string is a palindrome: "02020" is equal to its reverse "02020".
Therefore, the output for the given sample input of 2020 is "Yes".
Please note that this solution assumes that the input integer does not contain leading zeros initially. If the input integer already contains leading zeros, the solution may need to be adjusted accordingly.
I hope this helps! Let me know if you have any further questions.


Похожие вопросы
Топ вопросов за вчера в категории Информатика







Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili