思维加枚举

题意 :足球赛,赢平所得到的分数分别为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的更多相关文章

  1. CF 1244 C - The Football Season

    C - The Football Season 先考虑求解 \[ x\times w + y\times d=p \] 若存在一组解 \[ \begin{cases} x_0\\ y_0 = kw + ...

  2. [CF1244C] The Football Season【数学,思维题,枚举】

    Online Judge:Luogu,Codeforces Round #592 (Div. 2) C Label:数学,思维题, 枚举 题目描述 某球队一共打了\(n\)场比赛,总得分为\(p\), ...

  3. codeforces 432 B Football Kit

    题意:给出n支球队,主场的衣服的颜色x[i],客场的衣服的颜色y[i],每只队伍会打n-1次主场,n-1次客场,当这只队伍打客场的衣服颜色和对手一样的时候,那么他们要穿上主场的衣服 问每个球队主场球服 ...

  4. 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 ...

  5. codeforces 1244C (思维 or 扩展欧几里得)

    (点击此处查看原题) 题意分析 已知 n , p , w, d ,求x , y, z的值 ,他们的关系为: x + y + z = n x * w + y * d = p 思维法 当 y < w ...

  6. Python input/output boilerplate for competitive programming

    The following code is my submission for Codeforces 1244C The Football Season. import io import sys i ...

  7. Codeforces Round #592 (Div. 2)

    A. Pens and Pencils 题目链接:https://codeforces.com/contest/1244/problem/A 题意: 给定五个数 a , b , c , d , k 求 ...

  8. codeforces #592(Div.2)

    codeforces #592(Div.2) A Pens and Pencils Tomorrow is a difficult day for Polycarp: he has to attend ...

  9. American Football Vocabulary!

    American Football Vocabulary! Share Tweet Share You’ll learn all about the vocabulary of American fo ...

随机推荐

  1. 将String类型转换为int整数类型

    示例如下: public class demo { public static void main(String[] args) { String s="10"; 6 7 //St ...

  2. 交互程序 Scanner类

    交互程序 1. Scanner类是标准Java类库的类 (1)提供一些方法用于交互式读入不同类型的输入数据,输入可以是不同的数据源,包括用户键入的数据和保存在文件中的数据(怎么弄). (2)将一个字符 ...

  3. CSS块级-内联元素,盒子模型

    CSS元素 元素分类和区别 常用的块状元素有: <div>.<p>.<h1>~<h6>.<ol>.<ul>.<li> ...

  4. linux免密登录和设置别名

    一.免密登录 (1) 配置公钥   ssh-keygen (2)让远程服务器记住公钥   ssh-copy-id   用户名@ip地址或域名 二.设置别名 (3)在~/.ssh目录下创建并编辑conf ...

  5. Linux 使用 docker 下搭建xunsearch 搜索引擎服务

    Linux 使用 docker 下搭建 xunsearch 搜索引擎服务 安装 docker 环境(菜鸟教程有说明) 安装docker说明 下载并运行 xunsearch 的服务端:docker安装x ...

  6. 解密国内BAT等大厂前端技术体系-阿里篇(长文建议收藏)

    进入2019年,大前端技术生态似乎进入到了一个相对稳定的环境,React在2013年发布至今已经6年时间了,Vue 1.0在2015年发布,至今也有4年时间了. 整个业界在前端框架不断迭代中,也寻找到 ...

  7. MyBatis_多表关联查询_resultMap_单个对象_N+1方式实现

    mapper 层 提供 StudentMapper 和 ClazzMapper, StudentMapper 查询所有学生信息, ClazzMapper 根据编号查询班级信息. 再 StudentMa ...

  8. hdu-4638

    There are n men ,every man has an ID(1..n).their ID is unique. Whose ID is i and i-1 are friends, Wh ...

  9. MacOS下制作linux启动盘

    在Windows下,我们经常使用软碟通来制作各种系统的启动盘,那么在MacOS下,如何做到呢?MacOS跟Linux的做法基本一致.如果你只想快速地制作好启动盘,请看下面的快速版 首先,你需要以下两样 ...

  10. Altium PCB二维码Logo设计(转 crazybingo)

    Altium PCB二维码Logo设计 每次设计PCB的时候,都会在空白部分放Logo上去,一来板卡显得更充实,二来更有成就感一些... 今天突然想着...这两年二维码越来越火,火到快爆发,不如在板卡 ...