六十分求助

P6188 [NOI Online #1 入门组] 文具订购

huabuyan @ 2024-09-13 21:03:51

#include<iostream>
using namespace std;
int main(){
    int s;
    int ms=-1;
    int mb=-1;
    int a=0,b=0,c=0;
    cin>>s;
    if(s%14==0&&s!=0)
    {
        int b=s/14;
        cout<<b<<" "<<b<<" "<<b;
        return 0;
    }
    for(int i=0;i<s;i+=7)
    {
        for(int j=0;j<s;j+=4)
        {
            for(int l=0;l<s;l+=3)
            {
                if(i+j+l==s)
                {
                    if(min(i/7,min(j/4,l/3))>ms)
                    {
                        if(i/7+j/4+l/3>mb)
                        {
                            mb=i+j+l;
                            ms=min(i,min(j,l));
                            a=i/7;
                            b=j/4;
                            c=l/3;
                        }
                    }
                }
            }
        }
    }
    if(mb==-1)
    {
        cout<<-1;
    }
    else
    {
        cout<<a<<" "<<b<<" "<<c;
    }
    return 0;
}

by guoxinzhuo2012 @ 2024-10-16 22:18:12

ms和mb永远是-1


by guoxinzhuo2012 @ 2024-10-16 22:20:21

@guoxinzhuo2012 抱歉,看错了


|