51nod 1359 Cycle Quest

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.