当前位置:网站首页>Niu Mei's math problems
Niu Mei's math problems
2022-07-05 06:16:00 【whitewall_ nine】
#include<bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,l,r) for(int i=(l);i>=(r);i--)
#define ll long long
#define pii pair<int, int>
#define mset(s,t) memset(s,t,sizeof(t))
#define mcpy(s,t) memcpy(s,t,sizeof(t))
#define fir first
#define pb push_back
#define sec second
#define sortall(x) sort((x).begin(),(x).end())
inline int read () {
int x = 0, f = 0;
char ch = getchar();
while (!isdigit(ch)) f |= (ch=='-'),ch= getchar();
while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
return f?-x:x;
}
template<typename T> void print(T x) {
if (x < 0) putchar('-'), x = -x;
if (x >= 10) print(x/10);
putchar(x % 10 + '0');
}
#define int long long
const int N = 1e7 + 5;
const int mod = 998244353;
int n, k;
int fac[N], infac[N];
int a[N];
int pow2[N];
int qmi (int a, int b, int c) {
int ans = 1 %c;
while (b) {
if (b & 1) ans =ans * a % c;
b >>= 1;
a = a * a % c;
}
return (ans %c+ c)%c;
}
int C(int n,int m)
{
if(n<m) return 0;
return fac[n]*infac[m]%mod*infac[n-m]%mod;
}
void init () {
//cout << qmi(3, mod- 2, mod) << endl;
pow2[0] = 1;
fac[0] = 1;
for (int i =1; i< N ; i++)
fac[i] = fac[i - 1] * i %mod;
for (int i = 1; i < N; i++)
pow2[i] = pow2[i - 1] * 2 %mod;
infac[N - 1] = qmi (fac[N - 1], mod - 2, mod) %mod;
infac[0] = infac[1] = 1;
for (int i = N - 1; i>= 1; i--)
infac[i - 1] = infac[i] * i %mod;
}
void solve() {
cin >> n >> k;
init();
// cout << C(3, 1) << endl;
int one = 0, two = 0;
for (int i = 1; i <= n; i ++ )
{
cin >> a[i];
if (a[i] == 1) one ++;
else if (a[i] == 2) two ++;
}
int ans = 0;
for (int i = 0; i <= k; i++) {
ans = ((ans + C(one, i) * C(two, k - i) %mod * pow2[k - i] %mod + mod) %mod + mod) %mod;
}
cout << ans << endl;
}
signed main () {
int t;
t = 1;
while (t --) solve();
}
By looking at the data range , Statistics 1 and 2 The number of ,0 No contribution , Sure . This continuous summation can be regarded as a sequence . And the solution of inverse element , The linear method can be found by observing the formula , At first, I didn't think from the perspective of formula
边栏推荐
- LeetCode 0108.将有序数组转换为二叉搜索树 - 数组中值为根,中值左右分别为左右子树
- Arduino 控制的 RGB LED 无限镜
- Navicat连接Oracle数据库报错ORA-28547或ORA-03135
- Network security skills competition in Secondary Vocational Schools -- a tutorial article on middleware penetration testing in Guangxi regional competition
- 多屏电脑截屏会把多屏连着截下来,而不是只截当前屏
- Daily question 1984 Minimum difference in student scores
- LaMDA 不可能觉醒吗?
- One question per day 1020 Number of enclaves
- 【Rust 笔记】14-集合(上)
- LVS简介【暂未完成(半成品)】
猜你喜欢

4. 对象映射 - Mapping.Mapster

LeetCode 0107. Sequence traversal of binary tree II - another method

Network security skills competition in Secondary Vocational Schools -- a tutorial article on middleware penetration testing in Guangxi regional competition

做 SQL 性能优化真是让人干瞪眼

MySQL怎么运行的系列(八)14张图说明白MySQL事务原子性和undo日志原理

Leetcode-6110: number of incremental paths in the grid graph

实时时钟 (RTC)

Navicat連接Oracle數據庫報錯ORA-28547或ORA-03135

Appium automation test foundation - Summary of appium test environment construction

Appium自动化测试基础 — Appium测试环境搭建总结
随机推荐
Doing SQL performance optimization is really eye-catching
阿里巴巴成立企业数智服务公司“瓴羊”,聚焦企业数字化增长
Daily question 1189 Maximum number of "balloons"
做 SQL 性能优化真是让人干瞪眼
[rust notes] 16 input and output (Part 1)
The difference between CPU core and logical processor
LeetCode 1200. Minimum absolute difference
Shutter web hardware keyboard monitoring
Network security skills competition in Secondary Vocational Schools -- a tutorial article on middleware penetration testing in Guangxi regional competition
Erreur de connexion Navicat à la base de données Oracle Ora - 28547 ou Ora - 03135
[rust notes] 15 string and text (Part 1)
1039 Course List for Student
Leetcode-22: bracket generation
927. 三等分 模拟
927. Trisection simulation
【Rust 笔记】14-集合(上)
实时时钟 (RTC)
4. 对象映射 - Mapping.Mapster
leetcode-9:回文数
QQ computer version cancels escape character input expression