[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 ...
随机推荐
- for源码实现
for源码实现 我们知道,java的while和for基本上是实现一样的功能,这样会不会有一点缺点,同时java的迭代器显得尤为的麻烦. python的for和while就不同了,在实现迭代的功能的情 ...
- Vue项目功能插件
项目功能插件 vue-router { path: '/', name: 'home', // 路由的重定向 redirect: '/home' } { // 一级路由, 在根组件中被渲染, 替换根组 ...
- GItBook命令使用(持续更新)
GitBook基本命令 gitbook init //初始化目录文件 gitbook help //列出gitbook所有的命令 gitbook --help //输出gitbook-cli的帮助信息 ...
- 2019-2020-1 20199304《Linux内核原理与分析》第八周作业
第七章 Linux内核如何装载和启动一个可执行程序 一.知识点 1.ELF(Executable and Linkable Format)概述: "目标文件"指编译器生成的文件,& ...
- css6——通栏平均分布
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...
- Aria2GUI for macOS - 百度网盘高速下载
目录 一. aria2gui 1.1 下载地址:aria2gui 1.2 安装 1.2.1 方式一:手动安装 1.2.2 方式二:Homebrew安装 二. YAAW for Chrome 2.1 下 ...
- React中autoComplete="off" 失效
Turning Off Autocomplete in Chrome with React tl;dr Add a hidden input with an arbitrary value attri ...
- Spring事物实例
Spring事务实例: entity实体类: public class Accounts { private int accountid; private String accountname; pr ...
- [TimLinux] Python 修改进程显示出的标题
1. 安装依赖 https://github.com/timscm/py-setproctitle/archive/version-1.1.10.tar.gz 2. 启动进程 import timei ...
- 笔记||Python3之算法
循环嵌套:先从外层循环里面取出一个元素,再执行内层的循环:当内层的循环都执行后,再执行外层循环. for循环嵌套语法: for x in range(): for y in range() ...