# 2020.5.28 Educational Codeforces Round 88 比赛记录

### A Berland Poker

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define LL long long int
#define REP(i,n) for (int i = 1; i <= (n); i++)
#define Redge(u) for (int k = h[u],to; k; k = ed[k].nxt)
#define cls(s,v) memset(s,v,sizeof(s))
#define mp(a,b) make_pair<int,int>(a,b)
#define cp pair<int,int>
using namespace std;
const int maxn = 100005,maxm = 100005,INF = 0x3f3f3f3f;
int out = 0,flag = 1; char c = getchar();
while (c < 48 || c > 57){if (c == '-') flag = 0; c = getchar();}
while (c >= 48 && c <= 57){out = (out << 1) + (out << 3) + c - 48; c = getchar();}
return flag ? out : -out;
}
int main(){
int n,m,k,t;
while (T--){
t = n / k;
if (m <= t) printf("%d\n",m);
else {
int ans = t - (int)ceil(1.0 * (m - t) / (k - 1));
printf("%d\n",ans);
}
}
return 0;
}


### B New Theatre Square

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define LL long long int
#define REP(i,n) for (int i = 1; i <= (n); i++)
#define Redge(u) for (int k = h[u],to; k; k = ed[k].nxt)
#define cls(s,v) memset(s,v,sizeof(s))
#define mp(a,b) make_pair<int,int>(a,b)
#define cp pair<int,int>
using namespace std;
const int maxn = 100005,maxm = 100005,INF = 0x3f3f3f3f;
int out = 0,flag = 1; char c = getchar();
while (c < 48 || c > 57){if (c == '-') flag = 0; c = getchar();}
while (c >= 48 && c <= 57){out = (out << 1) + (out << 3) + c - 48; c = getchar();}
return flag ? out : -out;
}
int n,m,x,y,f[maxn],v[maxn],ans;
int main(){
while (T--){
for (int i = 1; i <= n; i++){
char c = getchar();
f[0] = 0;
for (int j = 1; j <= m; j++){
while (c != '.' && c != '*') c = getchar();
v[j] = c == '.' ? 0 : 1;
if (c == '*') f[j] = f[j - 1];
else {
f[j] = f[j - 1] + x;
if (j > 1 && !v[j - 1]) f[j] = min(f[j],f[j - 2] + y);
}
c = getchar();
}
ans += f[m];
}
printf("%d\n",ans);
}
return 0;
}


### C Mixing Water

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define LL long long int
#define REP(i,n) for (int i = 1; i <= (n); i++)
#define Redge(u) for (int k = h[u],to; k; k = ed[k].nxt)
#define cls(s,v) memset(s,v,sizeof(s))
#define mp(a,b) make_pair<int,int>(a,b)
#define cp pair<int,int>
using namespace std;
const int maxn = 100005,maxm = 100005,INF = 0x3f3f3f3f;
int out = 0,flag = 1; char c = getchar();
while (c < 48 || c > 57){if (c == '-') flag = 0; c = getchar();}
while (c >= 48 && c <= 57){out = (out << 1) + (out << 3) + c - 48; c = getchar();}
return flag ? out : -out;
}
int h,c,t;
int main(){
while (T--){
if (2 * t <= h + c) puts("2");
else {
int n = (h - t) / (2 * t - h - c);
double a = (1.0 * (n + 1) * h + 1.0 * n * c) / (2 * n + 1);
double b = (1.0 * (n + 2) * h + 1.0 * (n + 1) * c) / (2 * n + 3);
if (fabs(a - t) <= fabs(b - t)) printf("%d\n",2 * n + 1);
else printf("%d\n",2 * (n + 1) + 1);
}
}
return 0;
}


### D Yet Another Yet Another Task

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define LL long long int
#define REP(i,n) for (int i = 1; i <= (n); i++)
#define Redge(u) for (int k = h[u],to; k; k = ed[k].nxt)
#define cls(s,v) memset(s,v,sizeof(s))
#define mp(a,b) make_pair<int,int>(a,b)
#define cp pair<int,int>
using namespace std;
const int maxn = 100005,maxm = 100005,INF = 0x3f3f3f3f;
int out = 0,flag = 1; char c = getchar();
while (c < 48 || c > 57){if (c == '-') flag = 0; c = getchar();}
while (c >= 48 && c <= 57){out = (out << 1) + (out << 3) + c - 48; c = getchar();}
return flag ? out : -out;
}
int f[maxn],ans,n,a[maxn];
int main(){
for (int k = 0; k <= 30; k++){
for (int i = 1; i <= n; i++){
if (a[i] > k) f[i] = 0;
else f[i] = max(a[i],f[i - 1] + a[i]);
ans = max(ans,f[i] - k);
}
}
printf("%d\n",ans);
return 0;
}


### E Modular stability

$[1,n]$中取出$m$个互异的数，这些数组成的集合取模稳定，有多少种取法。

#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define LL long long int
#define REP(i,n) for (int i = 1; i <= (n); i++)
#define Redge(u) for (int k = h[u],to; k; k = ed[k].nxt)
#define cls(s,v) memset(s,v,sizeof(s))
#define mp(a,b) make_pair<int,int>(a,b)
#define cp pair<int,int>
using namespace std;
const int maxn = 500005,maxm = 100005,INF = 0x3f3f3f3f,P = 998244353;
int out = 0,flag = 1; char c = getchar();
while (c < 48 || c > 57){if (c == '-') flag = 0; c = getchar();}
while (c >= 48 && c <= 57){out = (out << 1) + (out << 3) + c - 48; c = getchar();}
return flag ? out : -out;
}
int fac[maxn],inv[maxn],fv[maxn],n,k;
void init(){
fac[0] = 1;
for (int i = 1; i <= 500000; i++) fac[i] = 1ll * fac[i - 1] * i % P;
inv[0] = inv[1] = 1;
for (int i = 2; i <= 500000; i++) inv[i] = 1ll * (P - P / i) * inv[P % i] % P;
fv[0] = 1;
for (int i = 1; i <= 500000; i++) fv[i] = 1ll * fv[i - 1] * inv[i] % P;
}
void work(){
if (n < k) puts("0");
else if (k == 1) printf("%d\n",n);
else {
int ans = 0;
for (int i = 1; n / i >= k; i++){
ans = (ans + 1ll * fac[n / i - 1] * fv[n / i - k] % P * fv[k - 1] % P) % P;
}
printf("%d\n",ans);
}
}
int main(){