CF1244C.The Football Season

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 ww points, and the opposing team gets 00 points. If the game results in a draw, both teams get dd points.

The manager of the Berland capital team wants to summarize the results of the season, but, unfortunately, all information about the results of each match is lost. The manager only knows that the team has played nn games and got pp points for them.

You have to determine three integers xx, yy and zz — the number of wins, draws and loses of the team. If there are multiple answers, print any of them. If there is no suitable triple (x,y,z)(x, y, z), report about it.

贝兰德足球赛季刚刚结束。根据贝兰德足球规则,每场比赛在两支队伍之间进行。每场比赛的结果要么是平局,要么是一方获胜。若一支队伍获胜,则获得 ww 分,而对手获得 00 分;若比赛以平局结束,则双方各得 dd 分。

贝兰德首都队的教练希望总结本赛季的成绩,但不幸的是,所有关于各场比赛结果的信息均已丢失。教练仅知道该队共进行了 nn 场比赛,并总共获得了 pp 分。

你需要确定三个整数 xx、yy 和 zz —— 分别表示该队的胜场数、平局数和负场数。若存在多组解,输出任意一组即可;若不存在满足条件的三元组 (x,y,z)(x, y, z),则报告无解。

输入格式

The first line contains four integers nn, pp, ww and dd (1≤n≤1012,0≤p≤1017,1≤d<w≤105)(1 \le n \le 10^{12}, 0 \le p \le 10^{17}, 1 \le d \lt w \le 10^{5}) — the number of games, the number of points the team got, the number of points awarded for winning a match, and the number of points awarded for a draw, respectively. Note that w>dw \gt d, so the number of points awarded for winning is strictly greater than the number of points awarded for draw.

第一行包含四个整数 nn、pp、ww 和 dd (1≤n≤1012,0≤p≤1017,1≤d<w≤105)(1 \le n \le 10^{12}, 0 \le p \le 10^{17}, 1 \le d \lt w \le 10^{5}),分别表示比赛场数、该队获得的总分数、获胜一场所得分数以及平局一场所得分数。注意 w>dw \gt d,即获胜所得分数严格大于平局所得分数。

输出格式

If there is no answer, print −1-1.

Otherwise print three non-negative integers xx, yy and zz — the number of wins, draws and losses of the team. If there are multiple possible triples (x,y,z)(x, y, z), print any of them. The numbers should meet the following conditions:

  • x⋅w+y⋅d=px \cdot w + y \cdot d = p,
  • x+y+z=nx + y + z = n.

如果没有答案,输出 −1-1。

否则,输出三个非负整数 xx、yy 和 zz —— 分别表示该队的胜场数、平场数和负场数。如果存在多个可能的三元组 (x,y,z)(x, y, z),输出其中任意一个即可。这些数字需满足以下条件:

  • x⋅w+y⋅d=px \cdot w + y \cdot d = p,
  • x+y+z=nx + y + z = n。

输入输出样例

  • 输入#1

    30 60 3 1

    输出#1

    17 9 4
  • 输入#2

    10 51 5 4

    输出#2

    -1
  • 输入#3

    20 0 15 5

    输出#3

    0 0 20

说明/提示

One of the possible answers in the first example — 1717 wins, 99 draws and 44 losses. Then the team got 17⋅3+9⋅1=6017 \cdot 3 + 9 \cdot 1 = 60 points in 17+9+4=3017 + 9 + 4 = 30 games.

In the second example the maximum possible score is 10⋅5=5010 \cdot 5 = 50. Since p=51p = 51, there is no answer.

In the third example the team got 00 points, so all 2020 games were lost.

第一个样例的一个可能答案是:1717 场胜利、99 场平局和 44 场失利。此时该队在 17+9+4=3017 + 9 + 4 = 30 场比赛中共获得 17⋅3+9⋅1=6017 \cdot 3 + 9 \cdot 1 = 60 分。

第二个样例中,最高可能得分是 10⋅5=5010 \cdot 5 = 50。由于 p=51p = 51,因此无解。

第三个样例中,该队得分为 00,因此全部 2020 场比赛均告失利。

输入解题思路,AI测评打分。不知道怎么写?

首页