Вопрос задан 19.06.2023 в 08:08. Предмет Информатика. Спрашивает Игоревич Кирилл.

ОЧЕНЬ СРОЧНО!!! ДАЮ 100 БАЛЛОВ Дается целое положительное число . Можно ли добавить

несколько(возможно ноль) ведущих нулей, чтобы стало числовым палиндромом? Числовой палиндром — это число, которое читается слева направо и справа налево одинаково. Веду́щие нули́ в записи числа — последовательность из одного или более нулей, стоящие в начале числа. Input Format В первой строке находится одно целое число . Изначально число не содержит ведущих нулей. Constraints Output Format Если можно сделать числовой палиндром, выведите "Yes". Иначе, выведите "No". Sample Input 0 2020 Sample Output 0 Yes
0 0
Перейти к ответам

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

Внимание! Ответы на вопросы дают живые люди. Они могут содержать ошибочную информацию, заблуждения, а также ответы могут быть сгенерированы нейросетями. Будьте внимательны. Если вы уверены, что ответ неверный, нажмите кнопку "Пожаловаться" под ответом.
Отвечает Крюкова Мария.

Ответ:

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')

Объяснение:

знаю, код мамбетский, но работает

0 0
Отвечает нейросеть ChatGpt. Будьте внимательны, ответы нейросети могут содержать ошибочные или выдуманные данные.

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.

0 0

Похожие вопросы

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

Последние заданные вопросы в категории Информатика

Задать вопрос