Python PodstawyŁatwe

Liczba automorficzna

Szczegółowy przewodnik i implementacja Python dla problemu „Liczba automorficzna”.

Oświadczenie o problemie

Łatwe

Napisz funkcję is_automorphic(n), która pobiera nieujemną liczbę całkowitą n i zwraca True, jeśli n jest liczbą automorficzną, lub False w przeciwnym razie. Liczba automorficzna to liczba, której kwadrat kończy się samą liczbą. Na przykład liczba 25 jest automorficzna, ponieważ 25^2 = 625, co kończy się na 25.

Ograniczenia
  • 0 <= n <= 10^6

Przykłady

Example 1
Input
n = 25
Output
True
Explanation

25^2 = 625. The last two digits of 625 are 25, which matches n.

Example 2
Input
n = 76
Output
True
Explanation

76^2 = 5776. The last two digits of 5776 are 76, which matches n.

Example 3
Input
n = 13
Output
False
Explanation

13^2 = 169. The last two digits of 169 are 69, which does not match 13.

Need a Hint?
Rozważ użycie struktur danych specyficznych dla podstaw, takich jak zestawy lub sterty.
Edge Cases to Watch
  • Puste struktury wejściowe
  • Wejścia jednoelementowe
  • Duże granice liczbowe

Gotowy do rozwiązania?

Open the problem in PyRun's browser-based Python editor. Your code runs fully offline — no server required.

Otwórz w Edytorze
Found this breakdown helpful?

PyRun is built and maintained by an independent solo developer. If this helped your interview prep, consider buying a coffee!

Buy me a coffee

Polecane zasoby Pythona

Poszerzaj swoją wiedzę dzięki powiązanym interaktywnym samouczkom, ściągawkom i porównaniom kodów.