-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMEXUM.cp
60 lines (49 loc) · 1.03 KB
/
MEXUM.cp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
#include<math.h>
using namespace std;
void insertionSort(int arr[], int n)
{
int i, k, j;
for (i = 1; i < n; i++)
{
k = arr[i];
j = i - 1;
while (j >= 0 && arr[j] > k)
{
arr[j + 1] = arr[j];
j = j - 1;
}
arr[j + 1] = k;
}
}
int main()
{
int t;
cin>>t;
const int m= 998244353;
while(t--)
{
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
int smallnumber=1, sum=1;
int siz=pow(2,n);
for(int i=1;i<siz;i++)
{
smallnumber=1;
for(int j=0;j<n;j++)
{
if(i & (1<<j))
{
if(arr[j]==smallnumber)
smallnumber++;
}
}
sum=(sum+smallnumber)%m;
}
cout<<sum<<"\n";
}
return 0;
}