题意加题解:
//x*w+y*d=p;
//x+y+z=0
int main()
{
ll n,p,w,d;
cin>>n>>p>>w>>d;
ll y=0;
while(y<w&&(p-d*y)%w) ++y;
if(y==w) return puts("-1"),0;
ll x=(p-d*y)/w;
if(x<0||x+y>n) return puts("-1"),0;
cout<<x<<" "<<y<<" "<<n-x-y<<" ";
//stop;
return 0;
}
原文地址:https://www.cnblogs.com/Herlo/p/12111925.html
时间: 2024-10-28 16:26:31