P10765 「CROI · R2」在相思樹下 I - 洛谷 | 電腦科學教育新生態 (luogu.com.cn)
挺簡單一題,看看規律即可。
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const int N = 70;
LL n, m;
int g[N];
int main()
{
int T;
cin >> T;
while (T -- )
{
cin >> n >> m;
for (int i = 1; i <= m; i ++ ) cin >> g[i];
LL res = 1;
for (int i = m; i; i -- )
{
res *= 2;
if (g[i] == 2) res -- ;
}
cout << res << endl;
}
return 0;
}