P10765 「CROI · R2」在相思树下 I

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;
}
posted @ 2024-07-14 11:52  blind5883  阅读(6)  评论(0编辑  收藏  举报