码迷,mamicode.com
首页 > 其他好文 > 详细

Codeforces Round #592 (Div. 2) C - The Football Season(推公式)

时间:2019-12-28 16:11:49      阅读:71      评论:0      收藏:0      [点我收藏+]

标签:==   alt   div   src   http   cout   cin   format   top   

?? ?? ??

题意加题解:

技术图片

//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;
}

Codeforces Round #592 (Div. 2) C - The Football Season(推公式)

标签:==   alt   div   src   http   cout   cin   format   top   

原文地址:https://www.cnblogs.com/Herlo/p/12111925.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!