QOJ.ac

QOJ

时间限制: 1 s 内存限制: 512 MB 总分: 100

#3968. 巨人之战

统计

著名的编程竞赛组织者决定举办一场冠军比赛“巨人之战”(The Battle of Giants)。比赛由两支队伍参加,共进行若干场比赛。

每场比赛的结果可能是其中一支队伍获胜,也可能是平局。当一支队伍获胜时,该队得 3 分,对方得 0 分。如果是平局,两队各得 1 分。所有比赛结束后,计算最终比分 $a:b$,其中 $a$ 和 $b$ 分别是第一支队伍和第二支队伍的总得分。

例如,如果第一场比赛由第一支队伍获胜,第二场比赛平局,第三场比赛也由第一支队伍获胜,那么最终比分为 $7:1$。

给定最终比分,请判断该比分是否可能,并求出最少需要进行的比赛场数。输出第一支队伍获胜的场数、平局的场数以及第二支队伍获胜的场数。

输入格式

第一行包含一个整数 $a$,表示第一支队伍的总得分。 第二行包含一个整数 $b$,表示第二支队伍的总得分。 给定的 $a$ 和 $b$ 均为非负整数且不超过 $10^9$。

输出格式

如果给定的最终比分不可能实现,输出 $-1$。 否则,输出三个整数:分别表示第一支队伍获胜的场数、平局的场数以及第二支队伍获胜的场数。请输出任意一种比赛场数最少的方案。

子任务

子任务 分值 数据范围
1 21 $0 \le a \le 50; b = 0$
2 23 $0 \le a, b \le 50; a = b$
3 25 $0 \le a, b \le 50$
4 31 $0 \le a, b \le 10^9$

样例

样例输入 1

7
1

样例输出 1

2 1 0

样例输入 2

2
1

样例输出 2

-1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.