传统题 1000ms 256MiB

Winner——全胜者

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Statement

NN teams participate in a chess team tournament. Each team consists of MM players. The tournament uses a round-robin format, with a total of N(N1)2\frac{N(N-1)}{2} games. In each game, the MM players from the two teams are randomly paired to play against each other, and each game is guaranteed to have a winner. After all games are completed, each player has played exactly N1N-1 games. If a player wins all games, they receive a win-win bonus. Find the maximum number of players who can receive a win-win bonus.

Input

The input consists of a single line of two numbers, N,MN,M, separated by a space, representing NN teams and MM players per team (2N1092 \leq N \leq 10^9, 1M1091 \leq M \leq 10^9).

Output

The output is a single number, tt, representing the maximum number of players who can win the perfect victory prize.

Samples

3 3
4
1 1
1

Notes

For the 11 test case, assume there are the following 33 teams participating in the competition.

  • Team TT: Players T1,T2,T3T_1, T_2, T_3;

  • Team WW: Players W1,W2,W3W_1, W_2, W_3;

  • Team RR: Players R1,R2,R3R_1, R_2, R_3;

The possible results of the game are as follows:

  • Team TT vs. Team WW:
    • T1T_1 vs. W1W_1, W1W_1 wins
    • T2T_2 vs. W2W_2, W2W_2 wins
    • T3T_3 vs. W3W_3, T3T_3 wins
  • Team TT vs. Team RR
    • T1T_1 vs. R3R_3, T1T_1 wins
    • T2T_2 vs. R1R_1, R1R_1 wins
    • T3T_3 vs. R2R_2, T3T_3 wins
  • Team WW vs. Team RR
    • W1W_1 vs. R3R_3, R3R_3 wins
    • W2W_2 vs. R2R_2, R2R_2 wins
    • W3W_3 vs. R1R_1, W3W_3 wins

At this point, only player T3T_3 from team TT wins the perfect victory prize. In this example, the maximum number of players who could win the perfect victory prize is 44.

2025 JSUT Collegiate Programming Contest 江苏理工学院新生赛-同步赛

未参加
状态
已结束
规则
ACM/ICPC
题目
15
开始于
2025-11-8 12:00
结束于
2025-11-8 17:00
持续时间
5 小时
主持人
参赛人数
15