loj2325"Tsinghua Training 2017" small y and terror slave master (expected probability + matrix fast power)

Source: Internet
Author: User
loj2325"Tsinghua Training 2017" Little Y and the horrible slave Lord

Original title address : https://loj.ac/problem/2325

Test Instructions:

"A fight?" Count me in! "to fight, count me in."

"Everyone, get in here!" everybody, come here.

Little Y is a oier who likes to play games. One day, she is playing a game, to play a boss.

Although the boss has 10100 10 100 10^{100} Points of health, it has only one attendant-a "horrible slave owner" with only M-m points of health.

This "horrible slave owner" has a special skill: whenever it is deducted from health but not dead (death is the health value ≤0≤0 \leq 0), and the boss's entourage is less than the upper limit K K K, it will summon a new "terror Slave" with M m points of health.

Now small y can do n n n attacks, each time the attack, from the boss and all the boss of the same probability of a random selection, and deduction of 1 1 1 points of health, she wants to know the n n n attacks after the boss's health points deduction of the expectation. To avoid accuracy errors, your answer needs to be modulo 998244353 998244353 998244353.

Data Range
1≤t≤1000,1≤n≤1018,1≤m≤3,1≤k≤8 1≤t≤1000, 1≤n≤10 18, 1≤m≤3, 1≤k≤8 1≤t≤1000,1≤n≤10^{18}, 1≤m≤3,1≤k≤8

The following:

The simplest DP, using the probability to calculate the expectation, record the first round, respectively, there are j,k,l of blood for the slave owner of the probability.
Dp[i+1][j′][k′][l′]+=k/j/lj+k+l+1dp[i][j][k][l] D p [i + 1] [j′] [k′] [l′] + = k/j/L j + k + L + 1 D p [i] [j] [K] [l] dp[i+1][j '][k '][l ']+=\frac{k/j/l}{j+k+l+1}dp[i][j][k][l],
each state has

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.