luogu#P6595. [YsOI2020] 计划
[YsOI2020] 计划
Background
I believe everyone already knows the following facts:
-
Ysuperman is very rich.
-
Ysuperman has always been good at making plans.
-
Ysuperman runs a kindergarten.
-
Ysuperman has collected some snacks.
-
Every day, they may suddenly feel like eating their snacks in a planned way.
Problem Description
Ysuperman currently has snacks. For each snack, every day there is a probability that they will make a plan for this snack. After days from the time they make a plan, they will eat this snack. A special note: if a plan has already been made for this snack before Ysuperman makes a new plan, then in practice the snack will be eaten according to the time of the first plan.
Unfortunately, greedy kids in the kindergarten may ruin this plan. There are kids in the kindergarten, and they are eyeing Ysuperman’s snacks. For each snack, every day there is a probability that it will be stolen and eaten by kid . If the snack has been eaten before some kid steals it, then correspondingly, that kid cannot steal it. If a snack is stolen before its plan is completed, then the related plan cannot be carried out.
Now Ysuperman wants to do a risk assessment of their plan. They offered a bounty of , and after multiple layers of subcontracting, the project has ended up in your hands. The values of these probabilities modulo have already been computed. After negotiation, if you solve this problem, you can get . You need to tell them the expected number of snacks Ysuperman can eat, and the expected number of days after which all of Ysuperman’s snacks are finished (eaten up).
If a snack is eaten by a kid, then that snack no longer belongs to Ysuperman.
Note that each day, Ysuperman makes plans before the kids attempt to steal the snacks.
Ysuperman thinks floating-point precision errors are too large, so you only need to output the answers modulo .
Input Format
The first line contains three positive integers , with meanings as described in the statement.
The second line contains one positive integer , representing the value of modulo .
The third line contains positive integers , each representing the value of modulo .
Output Format
One line with two non-negative integers, representing the expected number of snacks Ysuperman can eat, and the expected number of days after which Ysuperman’s snacks are finished. Output the answers modulo .
5 8 11
13482572
299473306 598946612 898419918 199648871 499122177 798595483 99824436 1
0 1
3 5 0
1
1 1 1 1 1
3 1
2 2 0
499122177
499122177 499122177
855638018 507044752
11 4 514
1919810
1919810 1919810 1919810 1919810
550831570 75142974
100000 20 227
2020
2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019
808786679 861511854
Hint
Sample Explanation
Sample Explanation :
One possible situation before taking modulo is:
5 8 11
0.1
0.1 0.2 0.3 0.4 0.5 0.6 0.7 1
In this case, the kids will steal and eat all snacks on the first day.
Sample Explanation :
One possible situation before taking modulo is:
3 5 0
1
1 1 1 1 1
In this case, Ysuperman will make plans and finish eating all snacks on the first day.
Sample Explanation :
One possible situation before taking modulo is:
2 2 0
0.5
0.5 0.5
In this case, the answers are and .
Since the solution process is rather complicated, please let smart readers think it through by themselves.
Constraints
If you only answer either one of the two questions correctly for a test point, you can get of the score for that test point.
Below is a partial scoring table as a tribute to : | Test Point ID | | | | | Special Property | | :-----------: | -----------: | -----------: | -----------: | -----------: | :-----------: | | 1 | | | | No other constraints | None | | 2 | | | | | | | 3 | | | | | | | 4 | | | | No other constraints | None | | 5 | | | | No other constraints | None | | 6 | | | | | | | 7 | | | | | | | 8 | | | | | | | 9 | | | | | | | 10 | | | | No other constraints | | | 11 | | | | No other constraints | None | | 12 | | | | No other constraints | | | 13 | | | | No other constraints | None | | 14 | | | | No other constraints | | | 15 | | | | | None | | 16 | | | | | None | | 17 | | | | | None | | 18 | | | | No other constraints | None | | 19 | | | | No other constraints | None | | 20 | | | | No other constraints | | | 21 | | | | No other constraints | None | | 22 | | | | No other constraints | None | | 23 | | | | No other constraints | None | | 24 | | | | No other constraints | None | | 25 | | | | No other constraints | |
For of the testdata, it holds that $1\le n\le 1919820,1\le m \le 114514,0\le T \le 2333,0\le P< 998244353,1\le p_i<998244353$.
Special property : There exists an such that .
Special property : All are equal.
Translated by ChatGPT 5