Incentive Model
题号:NC225779
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
64bit IO Format: %lld

题目描述

In the block-chain, miners compete for proposing a valid block to append it to the current blockchain, which is incentivized by rewards. The chance of winning the competition usually depends on the resource controlled by miners, e.g., computation power. Despite its popularity, PoW (Power of Work) incurs massive energy consumption as the mining competition relies on computation power. To eradicate the waste of computation resources, PoS (Power of Stake) protocols are invented, where the competition depends on staking power instead.

There is a PoS incentive model that uses the multi-lottery PoS incentive policy. Stakeholders of ML-PoS blockchains create a valid block if a candidate block satisfies the condition that , where represents the timestamp when the candidate block is generated. Since is uniformly distributed in the range , the event that a candidate block becomes valid is very well approximated to a Poisson random variable with a success probability of . Thus, if a miner possesses more stakes, he/she is more likely to create a new block successfully. Moreover, miners will try at different timestamps until a candidate block becomes valid. The trials are independent of timestamps following the same Poisson distribution.

Now, Cuber QQ considers the two-miner scenario where miner A and miner B are competing for proposing blocks in the network. Initially, the resource (stake) share of miner A (resp. B) is a (resp. b). Without loss of generality, a and b are normalized such that a+b=1. We refer to T_A (resp. T_B) as the number of timestamps miner A (resp. B) has checked until A (resp. B) meets the first success timestamp. It is easy to see that T_A and T_B follow geometric distributions with probability parameters and , respectively, i.e., , If miner A wins the next block, A must find a valid block earlier than B such that   .

Each turn, the miner who successfully creates a new block will be rewarded an incentive w, so the chance that A can win a block not only depends on the initial staking power (i.e., a) but also relies on previous mining outcomes. Specifically, the probability of A proposing a new block is determined by A's current staking power, including the initial stakes and the earned stakes. For example, if a miner is ``lucky'' to mine some blocks, his/her expected rewards will be improved in the future as the volume of her stakes increases. We also assume both miners A and B do not perform additional action after a mining game starts.

Cuber QQ uses (resp. ) to denote the fraction of the total reward that miner A (resp. B) received (obviously, ). Two miners are competing for n blocks in total. He now wants to know , i.e., the reward of miner A (number of the blocks that miner A will win) in expectation.

输入描述:

The first and only line contains four space-separated positive integers n, w, x and y (). Then and .

输出描述:

Output one integer --- the reward of miner A (number of the blocks that miner A will win) in expectation modulo 998244353.

Formally, let M=998244353. It can be shown that the answer can be expressed as an irreducible fraction , where p and q are integers and . Output the integer equal to . In other words, output such an integer x that and .
示例1

输入

复制
1 1 0 1

输出

复制
0