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

SRM 605 div 2 T3的更多相关文章

  1. TopCoder SRM 667 Div.2题解

    概览: T1 枚举 T2 状压DP T3 DP TopCoder SRM 667 Div.2 T1 解题思路 由于数据范围很小,所以直接枚举所有点,判断是否可行.时间复杂度O(δX × δY),空间复 ...

  2. Topcoder口胡记 SRM 562 Div 1 ~ SRM 599 Div 1

    据说做TC题有助于提高知识水平? :) 传送门:https://284914869.github.io/AEoj/index.html 转载请注明链接:http://www.cnblogs.com/B ...

  3. TopCoder SRM 560 Div 1 - Problem 1000 BoundedOptimization & Codeforces 839 E

    传送门:https://284914869.github.io/AEoj/560.html 题目简述: 定义"项"为两个不同变量相乘. 求一个由多个不同"项"相 ...

  4. 竞赛图的得分序列 (SRM 717 div 1 250)

    SRM 717 DIV 1 中 出了这样一道题: 竞赛图就是把一个无向完全图的边定向后得到的有向图,得分序列就是每个点的出度构成的序列. 给出一个合法的竞赛图出度序列, 要求构造出原图(原题是求(u, ...

  5. TopCoder SRM 605 DIV1

    604的题解还没有写出来呢.先上605的. 代码去practice房间找. 说思路. A: 贪心,对于每个类型的正值求和,如果没有正值就取最大值,按着求出的值排序,枚举选多少个类型. B: 很明显是d ...

  6. Topcoder SRM 648 (div.2)

    第一次做TC全部通过,截图纪念一下. 终于蓝了一次,也是TC上第一次变成蓝名,下次就要做Div.1了,希望div1不要挂零..._(:зゝ∠)_ A. KitayutaMart2 万年不变的水题. # ...

  7. SRM 638 Div.2

    250 给一个字符串 要求从一种形式换成另一形式 class NamingConvention{ private: int a, b, c; public: int d; string toCamel ...

  8. [topcoder]SRM 646 DIV 2

    第一题:K等于1或者2,非常简单.略.K更多的情况,http://www.cnblogs.com/lautsie/p/4242975.html,值得思考. 第二题:http://www.cnblogs ...

  9. [topcoder]SRM 633 DIV 2

    第一题,http://community.topcoder.com/stat?c=problem_statement&pm=13462&rd=16076 模拟就可以了. #includ ...

随机推荐

  1. AngularJS双向数据绑定

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  2. 一个简单jpa例子

    package com.example.demo.entity; import javax.persistence.*; /*使用jpa注解配置映射关系*/ /*告诉jpa这是一个实体类和(数据表映射 ...

  3. Android——线程通讯 Handler、Looper、Message;

    线程通讯问题 (主要用到了Handler类,Looper类和Message类以及MessageQueue) 在Android中主线程如何向子线程中发送消息的问题.让我们来想想,这其中的过程,无非就是创 ...

  4. python之路--MySQL数据库初识

    一 . MySQL安装 # 下载MySQL地址 https://dev.mysql.com/downloads # 要选稳定的,不要选最新的,稳定的就是半年以上没有出现过bug 现在5.6.43为绝大 ...

  5. Django进阶知识

    drf学习之Django进阶点 一.Django migrations原理 1.makemigrattions: 相当于在每个app下的migrations文件夹下生成一个py脚本文件用于创建表或则修 ...

  6. 自定义Attribute类

    在我们的项目中有时经常会标识一些类的特性,在下面我们将简短的方式来介绍如何构建自定义的Attribute类. using System; using System.Collections.Generi ...

  7. JDK 12 & JAVA

    JDK 12 & JAVA js style https://github.com/winterbe https://winterbe.com/posts/2018/09/24/java-11 ...

  8. ajax获得后台传来的一个json值,在js中获得其中的属性值

    首先 ajax的dataType需要设置为json, 默认的text获取属性值在jquery3.2.1中尝试不成功 获得属性值的方式: 类似数组,键值对的方式 下面例子: 设置dataType为jso ...

  9. 【python练习题】程序17

    #题目:输入一行字符,分别统计出其中英文字母.空格.数字和其它字符的个数. s = input('请输入字符串:') alf = 0 space = 0 digi = 0 other = 0 for ...

  10. Microsoft Bot Framework with LUIS

    今年微软的编程之美的主题是“对话即平台”,“人工智能”,要求参赛选手用到Bot Framework与Cognitive Services. 大多数人应该对这两个技术都不怎么熟悉吧,我就在这里写写自己所 ...