文章
82
粉丝
344
获赞
201
访问
758.0k
 
#include <bits/stdc++.h>
using namespace std;
struct node{
    double w;
    double m;
    double pow;// m/w; 
};
int m,n;
bool cmp(node a,node b){
    return a.pow<b.pow;
}
node a[10005];
int main(){
    while(cin>>m>>n){
        if((m==-1)&&(n==-1)) return 0;
        for(int i=0;i<n;i++){
            cin>>a[i].w>>a[i].m;
            a[i].pow=a[i].m/a[i].w;
        }
        sort(a,a+n,cmp);
        double res=0;
        int i=0;
        for(i=0;i<n;i++){
            if(m-a[i].m<=0){
 &n...
登录后发布评论
暂无评论,来抢沙发