Educational Codeforces Round 97 1437A Marketing Scheme

Topic link

Insert picture description here

Title translation:

You got a job as a pet shop salesperson. Your current task is to increase sales of cat food. One of the strategies is to pack multiple cans of cat food into a single product and sell them at discounts to attract users.
Suppose you decide to pack a can of cat food into a commodity, and when some customers want to buy x can of cat food, then he will buy according to the following greedy strategy:

  • He will buy [x/a] packaged goods first because there is a discount.
  • Then buy the remaining cans (x mod a), one by one.

[x/a] means x divides a (rounded down), and x mod a means x takes the remainder of a.
But the customer is also very greedy, so if the customer wants to buy x mod a can of cat food and (x mod a) ≥ a/2, then he will directly buy a can of cat food (instead of buying x mod a Cans of cat food). This will make you happy, because the customer bought more cans than he wanted to buy in the first place.
You already know that every customer will buy l to r cans of cat food (including l and r) in your store . Can you determine a value, so that customers bought more canned than the number he initially wanted to buy.

Problem-solving ideas:

First of all, we can determine that the value of a is not between [l,r] . If the value of a is between [l,r] , then the customer can directly choose to buy a can of cat food, so that the customer will only buy a can of cat food in the end, and will not buy more.
If a value is greater than the R & lt , a MOD X equals x, so long as l> = a / 2 on it, and a minimum value of R & lt +. 1 , so long as l * 2> = a , i.e., l * 2 When >r , no matter the sum of x, the end customer will buy more.
If the value of a is less than l , it seems not very easy to analyze.

Code:
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<cstdio>
#include<cmath>
#define inf 0x3f3f3f3f
using namespace std;
int main(){
    
    
//	freopen("1.txt","r",stdin);
	int t,l,r;
	cin>>t;
	while(t--){
    
    
		cin>>l>>r;
		if(l*2<=r){
    
    
			cout<<"NO"<<endl;
		}else{
    
    
			cout<<"YES"<<endl;
		}
	}
	return 0;
}

Guess you like

Origin blog.csdn.net/lmmmmmmmmmmmmmmm/article/details/109327378