2021牛客寒假算法基础集训营5,签到题BF
【摘要】
B 比武招亲(上)
/*
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int ...
B 比武招亲(上)
/*
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1e6+10;
const int mod = 998244353;
LL fac[maxn], inv[maxn];
LL mpow(LL a, LL x) {
if(x==0)return 1;
LL t = mpow(a, x>>1);
if(x%2==0)return t*t%mod;
return t*t%mod*a%mod;
}
LL init(){
fac[0]=inv[0]=1;
for(int i = 1; i < maxn; i++){
fac[i]=fac[i-1]*i%mod; inv[i]=mpow(fac[i],mod-2);
}return 0;
}
LL C(int x, int y) {
if(y<0 || y>x)return 0;
return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main(){
init();
ios::sync_with_stdio(false);
LL n, m; cin>>n>>m;
LL ans = 0;
for(LL i = 1; i <= n; i++){
ans += C(i+m-2-1,m-2)*(i-1)%mod*(n-i+1)%mod;
}
cout<<ans%mod<<"\n";
return 0;
}
- 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
F 我的心是冰冰的
/*
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main(){
ios::sync_with_stdio(false);
int T; cin>>T;
while(T--){
int n; cin>>n;
if(n==1){cout<<"1\n"; continue;}
for(int i = 1; i < n; i++){
int x, y; cin>>x>>y;
}
cout<<2<<"\n";
}
return 0;
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
文章来源: gwj1314.blog.csdn.net,作者:小哈里,版权归原作者所有,如需转载,请联系作者。
原文链接:gwj1314.blog.csdn.net/article/details/113950207
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)