[Codeforces 1244C] The Football Season
思维加枚举
题意 :足球赛,赢平所得到的分数分别为w和d,w>d,分别求赢平输的场数,输出一组即可,即x+y+z=n 且 xw+yd=p的一组解。
可以扩展公约数做,但由于注意到d和w<1e5的条件,可以枚举。
个人理解是由于dw=wd 就是说你用w场平的所得分和d场赢所得分是一样,所以我们就可以调整平的场数,由于题目有这样一句话
Note that w>dw>d, so the number of points awarded for winning is strictly greater than the number of points awarded for draw.
所以我们尽量让平的场数少,介于[0,w-1]之间,(显然平的场数超过这个区间的时候,我可以用d场赢的来替代,且由于d<w,所用的场数更少,另外的部分让其去输凑总场次即可)
所以就是枚举平的场数呀,大概记录一下思维。
#include <bits/stdc++.h>
#define debug(x) cout << #x << ": " << x << endl
using namespace std;
typedef long long ll;
const int MAXN=2e5+;
const int INF=0x3f3f3f3f; int main()
{
ios::sync_with_stdio(false);
cin.tie();
ll n,p,d,w;
cin>>n>>p>>w>>d;
ll x,y,z;
int ok=;
for(int i=;i<w;++i)
{
if((p-(i*d))%w==)
{
x=(p-i*d)/w;
y=i;
z=n-x-y;
if(x>= && y>= && z>=) {ok=;break;}
}
}
if(!ok) cout<<-<<endl;
else cout<<x<<' '<<y<<' '<<z<<endl;
return ;
}
[Codeforces 1244C] The Football Season的更多相关文章
- CF 1244 C - The Football Season
C - The Football Season 先考虑求解 \[ x\times w + y\times d=p \] 若存在一组解 \[ \begin{cases} x_0\\ y_0 = kw + ...
- [CF1244C] The Football Season【数学,思维题,枚举】
Online Judge:Luogu,Codeforces Round #592 (Div. 2) C Label:数学,思维题, 枚举 题目描述 某球队一共打了\(n\)场比赛,总得分为\(p\), ...
- codeforces 432 B Football Kit
题意:给出n支球队,主场的衣服的颜色x[i],客场的衣服的颜色y[i],每只队伍会打n-1次主场,n-1次客场,当这只队伍打客场的衣服颜色和对手一样的时候,那么他们要穿上主场的衣服 问每个球队主场球服 ...
- CF1244C The Football Season
题目链接 problem 给定\(n,p,w,d\),求解任意一对\((x,y)\)满足\[xw+yd=p\\ x + y \le n\] \(1\le n\le 10^{12},0\le p\le ...
- codeforces 1244C (思维 or 扩展欧几里得)
(点击此处查看原题) 题意分析 已知 n , p , w, d ,求x , y, z的值 ,他们的关系为: x + y + z = n x * w + y * d = p 思维法 当 y < w ...
- Python input/output boilerplate for competitive programming
The following code is my submission for Codeforces 1244C The Football Season. import io import sys i ...
- Codeforces Round #592 (Div. 2)
A. Pens and Pencils 题目链接:https://codeforces.com/contest/1244/problem/A 题意: 给定五个数 a , b , c , d , k 求 ...
- codeforces #592(Div.2)
codeforces #592(Div.2) A Pens and Pencils Tomorrow is a difficult day for Polycarp: he has to attend ...
- American Football Vocabulary!
American Football Vocabulary! Share Tweet Share You’ll learn all about the vocabulary of American fo ...
随机推荐
- GItBook命令使用(持续更新)
GitBook基本命令 gitbook init //初始化目录文件 gitbook help //列出gitbook所有的命令 gitbook --help //输出gitbook-cli的帮助信息 ...
- 转:<context:component-scan>使用说明
在xml配置了这个标签后,spring可以自动去扫描base-pack下面或者子包下面的java文件,如果扫描到有@Component @Controller@Service等这些注解的类,则把这些类 ...
- 一个普通程序员眼中的AQS
AQS是JUC包中许多类的实现根基,这篇文章只是个人理解的产物,不免有误,若阅读过程中有发现不对的,希望帮忙指出[赞]! 1 AQS内脏图 在开始了解AQS之前,我们先从上帝视角看看AQS是由几 ...
- Oracle_视图_索引_plsql_游标_存储过程_存储函数_触发器
-- 感觉有用点个赞呗^v^ select * from emp; drop view persin_vw;--删除视图 create table emp as select * from scott ...
- Python常用转义字符
\ 在行尾时是 续行符 \\ 反斜杠符号 \' 单引号 \" 双引号 \a 响铃 \b 退格 \e 转义 \000 空 \n 换行 \v 纵向制表符 \t ...
- springboot整合activiti
1.第一步添加bpmn文件得插件,不然没法查看和编辑bpmn文件,添加插件的方法各自百度即可,很简单 2.安装好bpmn插件后开始新建bpmn文件,也就是画流程图 一般是在代码中进行指定流程审批人的, ...
- luogu P1712 [NOI2016]区间
题目描述 在数轴上有 n个闭区间 [l1,r1],[l2,r2],...,[ln,rn].现在要从中选出 m 个区间,使得这 m个区间共同包含至少一个位置.换句话说,就是使得存在一个 x,使得对于每一 ...
- 决策树(三)决策树与Jupyter小部件的交互式可视化
简介 决策树是广泛用于分类和回归任务的监督模型. 在本文中,我们将讨论决策树分类器以及如何动态可视化它们. 这些分类器在训练数据上构建一系列简单的if / else规则,通过它们预测目标值. 在本演 ...
- CSS——overflow的参数以及使用
学习网站:https://developer.mozilla.org/zh-CN/docs/Web/CSS/overflow
- django----orm查询优化 MTV与MVC模型 choice参数 ajax serializers
目录 orm查询优化 only defer select_related 与 prefetch_related MTV 与 MVC 模型 choice参数 Ajax 前端代码 后端代码 前后端传输数据 ...