1 solutions
-
0
最大值一定在中间,所以你只需要决定其余的数放在最大数的左边还是右边,那么假如某个数出现的次数为x,并且不是最大的数,那么就可以选择放在左边的个数范围为[0,x],对应的右边的个数为[x,0],总共x+1种选择,因此序列的合法个数就是非最大值的数的个数加1再相乘 新生可以自己查查map怎么用,这也是经常用到的
#include <bits/stdc++.h> using namespace std; #define accelerate ios::sync_with_stdio(false),cin.tie(0); #define int long long #define PII pair<int,int> #define INF 0x3f3f3f3f #define fi first #define se second #define ufor(i,st,en) for(int i=st;i<=en;i++) #define dfor(i,en,st) for(int i=en;i>=st;i--) #define mp(x,y) make_pair(x,y) #define pb(x) emplace_back(x) #define vi vector<int> #define vii vector<vi> #define RE return 0 const int N=2e5+1000,mod=998244353; int n,m,k,T,z,q; //int d[13]= {0,31,28,31,30,31,30,31,31,30,31,30,31}; int dx[]={0,0,-1,0,1},dy[]={0,-1,0,1,0}; void fixd(int x){ cout<<setiosflags(ios::fixed)<<setprecision(x); } int mp[1000000]; void solve(){ cin>>n;int x,Max=-INF; map<int,int>mp; for(int i=1;i<=n;i++){ cin>>x;mp[x]++; Max=max(Max,x); } int ans=1; for(int i=1;i<Max;i++){ ans=ans*(mp[i]+1)%mod; } cout<<ans<<"\n"; } signed main(){ accelerate; T=1; while(T--){ solve(); } return 0; }
- 1
Information
- ID
- 6941
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 6
- Tags
- # Submissions
- 55
- Accepted
- 3
- Uploaded By