Start today to learn Java number to problem (complexity problem) __ Online programming

Source: Internet
Author: User

Question: There are x and y integer pairs, x and y are not greater than n,x divided by y the remainder is greater than or equal to K.

Train of thought: This topic looks very simple, only need two cycles can be done, but two loops are too complex, think about if the n=10^5 of the complexity of how high.

Here's a bunch of big guy ideas, just a loop.


Can be said to find the law, first divisor i is from the k+1 start to N, the divisor first take the number from K to I, so as to ensure that the remainder is greater than or equal to K. Then let dividend add the divisor and get another dividend, so that the remainder is the same as before.


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.