https://ac.nowcoder.com/acm/contest/64819
A
思路:除了最大的数外每个数有两种选择一个在最大的数左一个是右。所以每种数可以提供n+1种新组合
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<set>
#define Max 0x7fffffff
#define LL long long
#define ULL unsigned long long
#define N 200005
#define int long long
int mod = 998244353;
using namespace std;
int a[N],k,i,j;
signed main() {
int T; scanf("%lld", &T);
while (T--) {
map<int, int>mp;
int n; scanf("%lld", &n);
int num = 0, ans = 1, maxx = 0;
for (int i = 0; i < n; i++) {
scanf("%lld", &k);
mp[k]++;
maxx = max(maxx, k);
}
for (auto [i, j] : mp) {
if (i != maxx) {
ans = ans * (j + 1) % mod;
}
}
printf("%lld\n", ans);
}
}
B
思路:模拟一下,用map存cnt对应的x
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<set>
#define Max 0x7fffffff
#define LL long long
#define ULL unsigned long long
#define N 2000005
//#define int long long
int mod = 998244353;
using namespace std;
int main() {
int T; scanf("%d", &T);
while (T--) {
map<int, int>a;
int L, R, C; scanf("%d%d%d", &L, &R, &C);
int cnt = 0;
while (L <= R) {
cnt++;
int mid = (L + R) / 2;
a[cnt] = mid;
L = mid + 1;
}
if (a[C] == 0)printf("-1\n");
else
printf("%d\n", a[C]);
}
}