思维加枚举

题意 :足球赛,赢平所得到的分数分别为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. flanneld 安装

    目录 flanneld 安装 下载分发flanneld二进制文件 分发二进制文件到所有集群的节点 创建Flannel证书和私钥 创建证书签名请求 生成证书和私钥 向etcd写入Pod网段信息 创建fl ...

  2. Ansible Playbooks 介绍 和 使用 一

    目录 Ansible Playbooks Playbooks 组成部分: YAML 介绍 YAML 语法 Ansible 基础元素 变量 facts registre 通过命令传递变量 通过roles ...

  3. split分割(拆分)文件

    split分割(拆分)文件 需求:指定文件大小拆分文件 # ll -h test/ |grep vmcore -rw-r--r-- 1 root root  12G 12月  7 00:20 vmco ...

  4. ASP.NET Core3.X 终端中间件转换为端点路由运行

    引言 前几天.NET Core3.1发布,于是我把公司一个基础通用系统升级了,同时删除了几个基础模块当然这几个基础模块与.NET Core3.1无关,其中包括了支付模块,升级完后静文(同事)问我你把支 ...

  5. SmartSVN提示 svn: File has inconsistent newlines 解决

    用SmartSVN提交代码的时候提示:svn: File has inconsistent newlines 本文转自:http://www.youduoshao.com/2014-10-05/201 ...

  6. CF1009F Dominant Indices(启发式合并)

    You are given a rooted undirected tree consisting of nn vertices. Vertex 11 is the root. Let's denot ...

  7. (全国多校重现赛一) J-Two strings

    Giving two strings and you should judge if they are matched.  The first string contains lowercase le ...

  8. NET视频教程分享

    地址:链接:https://pan.baidu.com/s/1q47WN1XFw19vLZ8XZqnB_g    提取码:8ut2  这是我收集的一套.NET学习视频教程(某智24期视频),分享出来, ...

  9. java概述和java环境按照,java开发体验

    java概述: Java的发展可以归纳如下的几个阶段. (1)第一阶段(完善期):JDK 1.0 ( 1995年推出)一JDK 1.2 (1998年推出,Java更名为Java 2): (2)第二阶段 ...

  10. Xshell连接阿里云服务器

    1.遇到的问题 ​ 直接用阿里云的终端,还需要登录浏览器很是麻烦,所以用Xshell,ssh远程登录这样就轻松方便了很多. 2.打开 ​ 打开安装好的Xshell,点击新建 出现了这个界面,首先注意主 ...