思路:x,y,z肯定不为负数xw+dy=p,直接枚举系数较小的y即可,y的范围:y<w,因为大于w的时候,不如去增加x,这样x+y的和还能保持尽可能小.

 /*

 x*w+y*d=p;
x*w+(Kw+y)*d
(x+d)*w+d; x+y+z=n; */
#include<bits/stdc++.h> using namespace std;
#define int long long
signed main(){
int n,p,w,d;cin>>n>>p>>w>>d;
for(int y=;y<=w;y++){
int temp=p-y*d;
if(temp%w)
continue;
int x=temp/w;
if(x+y<=n&&x>=&&y>=&&(n-x-y)>=){
cout<<x<<" "<<y<<" "<<n-x-y;
return ;
}
}
cout<<"-1";
return ;
}

Codeforces Round #592 (Div. 2)【C题】{补题ING}的更多相关文章

  1. Codeforces Round #524 (Div. 2)(前三题题解)

    这场比赛手速场+数学场,像我这样读题都读不大懂的蒟蒻表示呵呵呵. 第四题搞了半天,大概想出来了,但来不及(中途家里网炸了)查错,于是我交了两次丢了100分.幸亏这次没有掉rating. 比赛传送门:h ...

  2. Codeforces Round #426 (Div. 2)A B C题+赛后小结

    最近比赛有点多,可是好像每场比赛都是被虐,单纯磨砺心态的作用.最近讲的内容也有点多,即便是点到为止很浅显的版块,刷了专题之后的状态还是~"咦,能做,可是并没有把握能A啊".每场网络 ...

  3. Codeforces Round #185 (Div. 2) B. Archer 水题

    B. Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/312/problem/B D ...

  4. Codeforces Round #360 (Div. 2) A. Opponents 水题

    A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...

  5. Codeforces Round #499 (Div. 2) Problem-A-Stages(水题纠错)

    CF链接  http://codeforces.com/contest/1011/problem/A Natasha is going to fly to Mars. She needs to bui ...

  6. Codeforces Round #796 (Div. 2)(A~E题题解)

    文章目录 原题链接: A.Cirno's Perfect Bitmasks Classroom 思路 代码 B.Patchouli's Magical Talisman 思路 代码 C.Manipul ...

  7. Codeforces Round #243 (Div. 2) B(思维模拟题)

    http://codeforces.com/contest/426/problem/B B. Sereja and Mirroring time limit per test 1 second mem ...

  8. Codeforces Round #340 (Div. 2) B. Chocolate 水题

    B. Chocolate 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co Bob loves everyt ...

  9. Codeforces Round #340 (Div. 2) A. Elephant 水题

    A. Elephant 题目连接: http://www.codeforces.com/contest/617/problem/A Descriptionww.co An elephant decid ...

随机推荐

  1. ARTS第七周打卡

    Algorithm : 做一个 leetcode 的算法题 ////////////////////////////////////////////////////////////////////// ...

  2. 20191011-构建我们公司自己的自动化接口测试框架-Util的AssertResult模块

    AssertResult主要就是进行结果断言的了,因为断言结果分2种情况,一种是断言词,一种是断言sheet,如果涉及断言sheet,则需要操作excel到对应的断言表断言所有的字段并且书写断言结果主 ...

  3. go 常量定义和使用

    常量的定义与变量类似,只不过使用 const 关键字. 常量可以是字符.字符串.布尔或数字类型的值. 常量不能使用 := 语法定义. 常量必须定义时赋值,不能多次赋值 package main imp ...

  4. SSM集成

    SSM集成   Spring和各个框架的整合   Spring目前是JavaWeb开发中最终的框架,提供一站式服务,可以其他各个框架整合集成   Spring整合方案   SSH Ssh是早期的一种整 ...

  5. Linux每隔1秒kill掉cpu大于50%的进程

    1.新建/test/killcpu.sh shell脚本 并授予权限0755#!/bin/bashps axf -o "pid %cpu" | awk '{if($2>=50 ...

  6. Jmeter5.1——聚合报告参数分析

    Jmeter5.1——聚合报告参数分析 Label: 每个JMeter的element的Name值.例如HTTP Request的Name. Samples:发出请求的数量.如果线程组中配置的是线程数 ...

  7. SMTP命令

    SMTP(Simple Mail Transfer Protocol)简单邮件传输协议 Basic Commands: HELO(Hello):标识用户身份 MAIL FROM:发件人地址 RCPT ...

  8. leetcode-63. Unique Paths II · DP + vector

    题面 A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). ...

  9. KVM之virsh管理Storage pool

    创建基于文件夹的存储池 基于文件夹的存储池: [root@ubuntu01 ~]# mkdir /data/vm_pool [root@ubuntu01 ~]# virsh pool-create-a ...

  10. golang GC(一 原理)

    golang中的gc采用三色标记法.在讲三色标记法之前,先了解一下Mark and Sweep算法,因为Mark and Sweep算法是三个标记法的一个改进版. Mark and Sweep算法: ...