链接
点击跳转
题解
他给的那个递推式其实就相当于 f i j = f i − 1 , j − 1 + f i − 1 , j f_{ij}=f_{i-1,j-1}+f_{i-1,j} fij=fi−1,j−1+fi−1,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,y−x+1)∑y(y−jx−1)
直接暴力做居然就过了…
标签有人写了“打表题”,不是很懂…懂的大佬请在下面留言
代码
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内容请搜索靠谱客的其他文章。
发表评论 取消回复