Programming contests

ECN programozó csapatverseny, 2019. május 11.

May 11, 2019, 10:15 AM – May 11, 2019, 3:15 PM

Numbers with Invariant Tail by Squaring

Notice the following interesting relation for these 3-digit numbers:

6252 = 390 625 = 625   mod 1000
3762 = 141 376 = 376   mod 1000

Notice also that if an n-digit number a has the property a2 = a   mod 10n, then also b = 10n + 1 – a has the same property, b2 = b   mod 10n. Indeed,

b2   mod 10n = (10n + 1 – a)2   mod 10n
= (1 – a)2   mod 10n
= 1 – 2a + a2   mod 10n
= 1 – 2a + a   mod 10n
= 1 – a   mod 10n
= 10n + 1 – a   mod 10n
= b   mod 10n

This explains the connection 625 + 376 = 1001.

Question: Are there numbers having 1000 digits that are equal to their square   mod 101000?

Input Specification

There is no input for this problem.

Output Specification

Print the text “NO” if there are no such numbers. If there exist such numbers, print the first 10 digits of each such number on a separate line.

University of Debrecen; Faculty of Informatics; v. 09/30/2024