Codeforces Round #592 (Div. 2)【C题】{补题ING}

思路: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}的更多相关文章
- Codeforces Round #524 (Div. 2)(前三题题解)
这场比赛手速场+数学场,像我这样读题都读不大懂的蒟蒻表示呵呵呵. 第四题搞了半天,大概想出来了,但来不及(中途家里网炸了)查错,于是我交了两次丢了100分.幸亏这次没有掉rating. 比赛传送门:h ...
- Codeforces Round #426 (Div. 2)A B C题+赛后小结
最近比赛有点多,可是好像每场比赛都是被虐,单纯磨砺心态的作用.最近讲的内容也有点多,即便是点到为止很浅显的版块,刷了专题之后的状态还是~"咦,能做,可是并没有把握能A啊".每场网络 ...
- 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 ...
- Codeforces Round #360 (Div. 2) A. Opponents 水题
A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...
- 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 ...
- Codeforces Round #796 (Div. 2)(A~E题题解)
文章目录 原题链接: A.Cirno's Perfect Bitmasks Classroom 思路 代码 B.Patchouli's Magical Talisman 思路 代码 C.Manipul ...
- Codeforces Round #243 (Div. 2) B(思维模拟题)
http://codeforces.com/contest/426/problem/B B. Sereja and Mirroring time limit per test 1 second mem ...
- Codeforces Round #340 (Div. 2) B. Chocolate 水题
B. Chocolate 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co Bob loves everyt ...
- Codeforces Round #340 (Div. 2) A. Elephant 水题
A. Elephant 题目连接: http://www.codeforces.com/contest/617/problem/A Descriptionww.co An elephant decid ...
随机推荐
- python标准库之collections介绍
collections----容器数据类型 collections模块包含了除list.dict.和tuple之外的容器数据类型,如counter.defaultdict.deque.namedtup ...
- WUSTOJ 1274: 喂,这里是帅帅的LCM(Java)
1274: 喂,这里是帅帅的LCM 题目 在一组数中,找出个数为奇数的数.更多内容点击标题. 分析 其实这种题并不难,做过一次之后,绝对不会错第二次.通过读题可以发现,我们要找的那个数在这一堆 ...
- 在Yii2中集成Markdown编辑器
安装命令: composer require ijackua/yii2-lepture-markdown-editor-widget:dev-master 可能会遇到的问题 如果在下载依赖包的过程中出 ...
- 【动态规划】Überwatch
Überwatch 题目描述 The lectures are over, the assignments complete and even those pesky teaching assista ...
- Quartz.net任务调度(石英钟定时任务)
好了,现在具体来说一下怎么使用Quartz.net 2.0. 1.到网上下载Quartz.net 2.0,下载完后解压,里面有vs.net2008和vs.net2010两个版本. 2.新建一个空项目, ...
- Abp 领域事件简单实践 <三> 自定义事件
熵片用到的 EntityCreatedEventData<TEntity>,继承自EventData. 我们可以自定义事件: public class TestEvent: EventD ...
- 学习笔记-Rabin-Karp哈希
在数学一本通上看过这两人名字,现在又出现了... 思想: 用一个整数表示一个字符串 \(w_{str}\)=(\(a_0\) \(p^{n-1}\)+\(a_1\) \(p^{n-2}\)+...+\ ...
- Go part 2 基础语法
关键字.标识符 标识符: 是用户或系统定义的有意义单词组合,或单词与数字组合(具体意义有定义者决定) 标识符以字母下划线开头,大小写敏感,比如:boy, Boy, _boy, _(匿名变量,用来 ...
- pymsql及事务
MySQL知识点补充 1.去重 distinct select distinct name,age from t1; # 针对查找出来的结果整行(记录)进行去重,也就是相同行只保存一个 注意点:dis ...
- Go微服务 grpc/protobuf
了解grpc/protobuf gRPC是一个高性能.通用的开源RPC框架,其由Google主要面向移动应用开发并基于HTTP/2协议标准而设计,基于ProtoBuf(Protocol Buffers ...