The coin

https://ac.nowcoder.com/acm/contest/879/B

Links: https://ac.nowcoder.com/acm/contest/879/B
Source: Cattle-off network

You practice dp, every time you have a probability of success p, 1-p is the probability of failure
after seeking investment n times, there are at least k times the probability of success
998244353 answer mode, wherein 0≤k, n≤105,0≤p <9,982,443,530 \ Le K, n-\ ^ 10 5,0 Le \ Le P <998 244 353 0 K , n- . 1 0 . 5 , 0 P < . 9 . 9 . 8 2 . 4 . 4 . 3 . 5 . 3
Actually give you the lower die 998 244 353 probability sense, in other sentences said p≡ab (mod998244353) P \ equiv \ FRAC {A} {B} \ {998 244 353} PMOD P B A ( m O D . 9 . 9 . 8 2 . 4 . 4 . 3 . 5 . 3 )

Enter a description:

The first row of three integers n, k, p

Output Description:

Row shows the results of an answer to an integer modulo 998 244 353
Example 1

Entry

copy
34 21 56

Export

copy
345 738 771 
Solution: from k to n, individually enumerated, is calculated as C (n, i) * p ^ i * (1-p) ^ (ni); (C is a combination of numbers);
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1E5+7;
const int mod=998244353;
ll ksm(ll x,  ll y){
    ll res=1;
    while(y){
        if(y&1) res=res*x%mod;
        x=x*x%mod;
        y>>=1;
    }
    return res%mod;
}
ll c(ll n,ll m){
    if(m>n)return 0;
    ll a=1,b=1;
    for(int i=1;i<=m;i++){
        a=a*(n+i-m)%mod;
        b=b*i%mod;
    }
    return a*ksm(b,mod-2)%mod;
}
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    ll ans=0;
    ll temp= c(n,m); 
    for(int i=m;i<=n;i++){
        ans = (ANS% + v (temp% v ksm * (k, i) * v% KSM ( 1 -k, Ni) v%)% v)% v; 
        temp = (((temp * (n)) v%) * ksm (i + 1 , MOD 2 ))% v; 
    } 
    Cout << (ANS + v)% v << endl;
    return  0 ; 
}

 




Guess you like

Origin www.cnblogs.com/Accepting/p/11447295.html