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 10^{17},1\le d<w \le 10^5\) solution 注意到\(n,p\)非常大,\(w,d\)比较小.而且\(w>d\).所以我们就想让\(y\)尽量小. 实际上如果最终有解,那在\(y\le w\)中肯定有解. 证明如下: 如果有\(y'=aw+k(a\ge 1,0\le…
Online Judge:Luogu,Codeforces Round #592 (Div. 2) C Label:数学,思维题, 枚举 题目描述 某球队一共打了\(n\)场比赛,总得分为\(p\),已知赢一场得\(w\)分,平局一场得\(d\)分,输一场不加分也不减分,问一共赢了几场(x),平局了几场(y),输了几场(z)?如果不存在合法方案输出"-1",如果存在多组可能的方案,任意输出一组(Special Judge). 也就是任求一组符合条件的非负整数三元组\((x,y,z)\)…
C - The Football Season 先考虑求解 \[ x\times w + y\times d=p \] 若存在一组解 \[ \begin{cases} x_0\\ y_0 = kw + v & (0<v<w)\\ \end{cases} \] 则 \[ x_0 \times w + y_0 \times d = p\\ \Rightarrow x_0 \times w + (kw+v)\times d = p\\ \Rightarrow x_0\times w + k\…
思维加枚举 题意 :足球赛,赢平所得到的分数分别为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 gr…
American Football Vocabulary! Share Tweet Share You’ll learn all about the vocabulary of American football in this video.  I’ll teach you how to understand the basic rules of the game, show you how to pronounce the key American football terms and hel…
The football season has just ended in Berland. According to the rules of Berland football, each match is played between two teams. The result of each match is either a draw, or a victory of one of the playing teams. If a team wins the match, it gets …
A. Pens and Pencils 题目链接:https://codeforces.com/contest/1244/problem/A 题意: 给定五个数 a , b , c , d , k 求一对 x , y 使得 cx >= a , dy >= b , 且 x + y <= k 若无法找到满足条件的 x , y ,则输出 - 1 分析: 判断 a 是否能除尽 c , 如果能 , 则 x 最小可以为 c / a , 否则 x 最小可以为 a / c + 1 再判断 b 是否能除尽…
codeforces #592(Div.2) A Pens and Pencils Tomorrow is a difficult day for Polycarp: he has to attend a lectures and b practical classes at the university! Since Polycarp is a diligent student, he is going to attend all of them. While preparing for th…
The following code is my submission for Codeforces 1244C The Football Season. import io import sys import math def inverse(a, m): u = 0 v = 1 while a != 0: t = m // a m -= t * a a, m = m, a u -= t * v u, v = v, u assert m == 1 return u def main(): #…
Problem - A Tomorrow is a difficult day for Polycarp: he has to attend \(a\) lectures and \(b\) practical classes at the university! Since Polycarp is a diligent student, he is going to attend all of them. While preparing for the university, Polycarp…