我是靠谱客的博主 现代老鼠,这篇文章主要介绍nowcoder15550 箱庭的股市链接题解代码,现在分享给大家,希望可以做个参考。

链接

点击跳转

题解

他给的那个递推式其实就相当于 f i j = f i − 1 , j − 1 + f i − 1 , j f_{ij}=f_{i-1,j-1}+f_{i-1,j} fij=fi1,j1+fi1,j

根据题意写出

a n s = ∑ j = m a x ( 0 , y − x + 1 ) y ( x − 1 y − j ) ans = sum_{j=max(0,y-x+1)}^y binom{x-1}{y-j} ans=j=max(0,yx+1)y(yjx1)

直接暴力做居然就过了…

标签有人写了“打表题”,不是很懂…懂的大佬请在下面留言

代码

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define iinf 0x3f3f3f3f #define linf (1ll<<60) #define eps 1e-8 #define maxn 1000010 #define maxe 1000010 #define cl(x) memset(x,0,sizeof(x)) #define rep(_,__) for(_=1;_<=(__);_++) #define em(x) emplace(x) #define emb(x) emplace_back(x) #define emf(x) emplace_front(x) #define fi first #define se second #define de(x) cerr<<#x<<" = "<<x<<endl using namespace std; using namespace __gnu_pbds; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; ll read(ll x=0) { ll c, f(1); for(c=getchar();!isdigit(c);c=getchar())if(c=='-')f=-f; for(;isdigit(c);c=getchar())x=x*10+c-0x30; return f*x; } #define mod 1'000'000'007ll ll fact[maxn], inv[maxn], _fact[maxn]; ll C(ll n, ll m) { if(n<0 or m<0 or m>n)return 0; return fact[n]*_fact[m]%mod*_fact[n-m]%mod; } int main() { ll i, T, m, x, y, p, j; inv[1]=1; for(i=2;i<maxn;i++)inv[i]=inv[mod%i]*(mod-mod/i)%mod; fact[0]=_fact[0]=1; rep(i,maxn-1)fact[i]=fact[i-1]*i%mod, _fact[i]=_fact[i-1]*inv[i]%mod; while(~scanf("%lld%lld%lld%lld",&m,&x,&y,&p)) { ll ans=0; for(j=max(0ll,y-x+1);j<=y;j++)(ans+=C(x-1,y-j))%=mod; ans=ans*p%mod; printf("%lldn",ans); } return 0; }

最后

以上就是现代老鼠最近收集整理的关于nowcoder15550 箱庭的股市链接题解代码的全部内容,更多相关nowcoder15550内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(49)

评论列表共有 0 条评论

立即
投稿
返回
顶部