2种解法!!!
2025-04-20 17:30:50
发布于:广东
3阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;//a表示饥饿值,b表示持有的钱
	cin>>a>>b;
	int x1,x2,x3;//表示3种食物的饱腹度 
	int y1,y2,y3;//表示3种食物的价格 
	cin>>x1>>y1>>x2>>y2>>x3>>y3;
	int min=b/y1;
	int min1=b/y2;
	int min2=b/y3;
	int man=x1*min;
	int man1=x2*min1;
	int man2=x3*min2;
	if(man>=a) cout<<"YES"<<endl;
	else if(man1>=a) cout<<"YES"<<endl;
	else if(man2>=a) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	/*
解法二:
	if(b>=y1){
		if(man>=a) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}else if(b>=y2){
		if(man1>=a) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}else if(b>=y3){
		if(man2>=a) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}else cout<<"NO"<<endl;
	*/
    return 0 ;
}
这里空空如也

有帮助,赞一个