Codeforces 397B on corruption and numbers-yy-(the integer within the interval can be formed into an integer)

Source: Internet
Author: User

Test instructions: To find whether a continuous integer can be formed into an integer n. Unlimited number of integers within a range

Analysis: The problem of the coin chip, so I just started thinking is DP, infinite backpack, but found not knapsack problem, but I still think it is a DP, so wrote a transfer equation, it seems to be right, ready to write code when the use of DP words, the array simply can not open so big 10^ 9, so I am sure is not DP, according to experience that should be a yy problem, and then began to manually find the law, found that: as long as n in the interval k[l,r] inside, you can use the integer in the interval to make n, in other words, can find a valid K can, namely: N/R <= n/l, pay attention to: when n%r= =0 when the left end point directly with N/R, otherwise to use n/r+1, here to notice, in many problems have this small details.

Code:

#include <iostream>using namespace Std;int main () {int t;int n,l,r;cin>>t;while (t--) {cin>>n>> L>>r;int a=n/l;int b;if (n%r==0) b=n/r;else b=n/r+1;if (b<=a) cout<< "Yes" <<endl;else cout<< "No" <<endl;}}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Codeforces 397B on corruption and numbers-yy-(the integer within the interval can be formed into an integer)

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.