SRM 605 div 2 T3

Posted wjnclln

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SRM 605 div 2 T3相关的知识,希望对你有一定的参考价值。

#include <bits/stdc++.h>
#define Mo 1000000007
#define MAXN 50
#define MAXK 10
using namespace std;
int dp[2*MAXN+2][1<<MAXK];
class AlienAndSetDiv2 {
public:
    int N, K;
    int calc(int n, int unmatched)
    {
        int res = 0;
        if (-1 != dp[n][unmatched]) {
            return dp[n][unmatched];
        }
 
        if (n == 2 * N + 1) {
            if (0 == unmatched) {
                res = 1;
            }
        } else {
            if (0 == unmatched) {
                res += ( 2 * calc(n + 1, 1) ) % Mo;
            } else {
                int newset = unmatched;
                int i = 0;
                for (i = 0; (newset & 0x80000000 ) == 0; newset = ( newset << 1 ), ++i) {
                }
                int mx = 31 - i;
                res += calc(n + 1,  (unmatched - (1 << mx)) << 1 );    
                res %= Mo;
 
                if (mx != K - 1) {
                    newset = unmatched;
                    newset = ( (newset << 1) | 1 );
                    res += calc(n + 1, newset);
                    res %= Mo;
                }
            }    
        }
        dp[n][unmatched] = res;
        return res;
    }

 

以上是关于SRM 605 div 2 T3的主要内容,如果未能解决你的问题,请参考以下文章

topcoder srm 605 div1

汕头市队赛 SRM10 T3 数学上来先打表

汕头市队赛 SRM13 T3

汕头市队赛SRM 20 T3 灵魂觉醒

汕头市队赛SRM14 T3覆盖

汕头市赛srm1X T3