P5675 [GZOI2017]取石子游戏(博弈,没太懂)

https://www.luogu.com.cn/problem/P5675

 

 

 

#include <bits/stdc++.h>

using namespace std;
#define int long long
const int mod = 1e9 + 7;

int n, a[205], dp[205][260], ans;

signed main() {
    //freopen("in","r",stdin);
    ios::sync_with_stdio(0);
    cin >> n;
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            for (int k = 0; k < 256; k++) {
                if (i == j) dp[j][k] = dp[j - 1][k];//这里一定要跳过,去掉我们枚举的“第一堆”
                else dp[j][k] = (dp[j - 1][k] + dp[j - 1][k ^ a[j]]) % mod;
            }
        }
        for (int j = a[i]; j < 256; j++)
            ans = (ans + dp[n][j]) % mod;//统计第i堆作为第1堆的答案
    }
    cout << ans;
    return 0;
}

 

posted @ 2020-03-24 11:12  Hazelxcf  阅读(203)  评论(0编辑  收藏  举报