#P16239. [蓝桥杯 2026 省 B] 足球训练
[蓝桥杯 2026 省 B] 足球训练
Problem Description
Xiaolan is the captain of a football team, and he is preparing for the next important match. Over the next days, each day he can choose one player to train, and once chosen, the training target for that day cannot be changed.
There are players in the team. For player , we know:
- The initial strength value is .
- The talent value is .
The training rules are as follows:
- If Xiaolan trains player on some day, then on that day the player’s strength value increases by .
- If player is trained for a total of days, then the player’s final strength value becomes: .
The overall strength of the team is defined as the product of all players’ final strength values, i.e.:
where is the number of training days assigned to player , and it satisfies:
Xiaolan hopes to maximize the team’s overall strength by allocating these training days reasonably. Since the result may be very large, you only need to output the maximum value modulo .
Input Format
The input has lines.
The first line contains two positive integers , representing the number of players and the total number of days available for training.
The next lines each contain two positive integers , representing the initial strength value and the talent value of player .
Output Format
Output one line containing one non-negative integer, representing the maximum possible team strength after days of training, modulo .
2 3
4 2
5 3
66
Hint
Sample Explanation
One optimal plan is:
- Train player for day.
- Train player for days.
Then:
- Player ’s final strength is .
- Player ’s final strength is .
The team’s overall strength is , so the output is .
Constraints
For of the testdata, .
For of the testdata, .
For of the testdata, , , .
Translated by ChatGPT 5