1359 Circular Quest
Enter n and K for minimum x (x>1) x (x > 1) to make nx%10k==n%10k n^x \% 10^k = = N \% 10^k
X>1 is required here, because X==1 must have n1%10k==n%10k n^1 \% 10^k = n \% 10^k
First recall the simple multiplication of large numbers.
For two large numbers, a, b ,
Make a∗b=c a*b=c
Among them A[i],b[i],c[i] a[i], b[i], C[i]
Number I for the large number, respectively
Because: a∗b% 10k= (a%10k+b%10k)%10k=c%10k a*b \ \%\ 10^k\\= (a\%10^k+b\%10^k) \%10^k\\=c\%10^k
Therefore: C[0...K] can be obtained by A[0...K]∗B[0...K] [0...K] means that the corresponding large number of No. 0 to K bit C[0...K] can be obtained by A[0...K]*B[0...K] \ [0...K] Represents the No. 0 to k digits of the corresponding large number
The process of multiplication in large numbers. Direct truncation; (Suggested naïve algorithm
Because we're going to make sure that a minimum x makes n