Painting Square

转换一下变成 a 层的完全四叉树, 占领 k 个点有多少种方案, 点能被占当且仅当它的父亲被占。

a <= 30, 所以我们把每层都dp出来, dp[ i ][ j ] 表示 i 层完全四叉树占领 k 个点的方案数。

#include<bits/stdc++.h>
#define LL long long
#define LD long double
#define ull unsigned long long
#define fi first
#define se second
#define mk make_pair
#define PLL pair<LL, LL>
#define PLI pair<LL, int>
#define PII pair<int, int>
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(), (x).end()
#define fio ios::sync_with_stdio(false); cin.tie(0);using namespace std;const int N = 5000 + 7;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 7340033;
const double eps = 1e-8;
const double PI = acos(-1);template<class T, class S> inline void add(T &a, S b) {a += b; if(a >= mod) a -= mod;}
template<class T, class S> inline void sub(T &a, S b) {a -= b; if(a < 0) a += mod;}
template<class T, class S> inline bool chkmax(T &a, S b) {return a < b ? a = b, true : false;}
template<class T, class S> inline bool chkmin(T &a, S b) {return a > b ? a = b, true : false;}int dp[31][1007];
int q, n, k;int main() {dp[0][0] = 1;for(int o = 1; o < 31; o++) {dp[o][0] = 1;dp[o][1] = 1;for(int c = 0; c < 4; c++) {for(int i = 1000; i >= 1; i--) {for(int j = 1; i + j <= 1000; j++) {add(dp[o][i + j], 1LL * dp[o][i] * dp[o - 1][j] % mod);}}}}scanf("%d", &q);while(q--) {scanf("%d%d", &n, &k);int c = 0;while((n & 1) && n != 1) {c++;n--;n >>= 1;}printf("%d\n", dp[c][k]);}return 0;
}/*
*/

转载于:https://www.cnblogs.com/CJLHY/p/11099739.html

Codeforces 300D Painting Square dp相关推荐

  1. [CodeForces 300D Painting Square]DP

    http://codeforces.com/problemset/problem/300/D 题意:每一次操作可以选一个正方形,令边长为n,如果n为奇数那么可以从中间画一个十字,分成4个大小相等的边长 ...

  2. Codeforces 300D Painting Square 题解

    题意 一个四周围都是黑色的由n行n列小格子组成的方块,每次可以选择一个已经由黑框包围的正方形将它的一行一列涂黑要求分割出的部分还都是正方形,问涂k次可以有多少种不同的涂法 思路 因为只能分割成正方形, ...

  3. Codeforces 919D Substring (拓扑图DP)

    Codeforces 919D Substring (拓扑图DP) 手动博客搬家: 本文发表于20180716 10:53:12, 原地址https://blog.csdn.net/suncongbo ...

  4. [CodeForces 332B]Maximum Absurdity[DP]

    题目链接: [CodeForces 332B]Maximum Absurdity[DP] 题意分析: 寻找两个不重叠的长度为k的子串,使得它们之和最大. 解题思路: 第一想法是,处理出从这个点开始,长 ...

  5. 【CodeForces 1042B --- Vitamins】DP+位运算

    [CodeForces 1042B --- Vitamins]DP+位运算 题目来源:点击进入[CodeForces 1042B - Vitamins] Description Berland sho ...

  6. CodeForces - 1480D2 Painting the Array II(dp)

    题目链接:点击查看 题目大意:给出一个长度为 nnn 的序列,现在要求拆分成两个子序列,使得两个子序列的贡献之和最 小.对于一个序列的贡献就是,去掉相邻且相同的字母后的长度,即 ∑i=1n[a[i]! ...

  7. [Codeforces Round #195 DIV2E (CF336E)] Vasily the Bear and Painting Square

    题意 当n=0n=0时有如下图像 当n=1n=1时有如下图像 当n=2n=2时有如下图像 题目要求对定的nn的图像,染k个三角形(并不要求染最小的三角形),求染色方案数. 需要注意的是:即使染色完毕后 ...

  8. Codeforces 1322D Reality Show (DP)

    题目链接 https://codeforces.com/contest/1322/problem/D 题面写得非常模糊,很容易读错题,建议参考翻译:https://www.luogu.com.cn/p ...

  9. CodeForces - 1579G Minimal Coverage(dp)

    题目链接:点击查看 题目大意:给出 nnn 个长度不同的木棍.设第 i−1i-1i−1 次放置木棍后的终点为 xxx,那么第 iii 个木棍有且仅有两种放置方法: 放到 [x+1,x+a[i]][x+ ...

最新文章

  1. python中如何调用java_在Python程序中调用Java代码的实现
  2. hdu 2665 Kth number 划分树
  3. 致年轻开发人员的一封信
  4. 我怀疑对象做了什么对不起我的事......
  5. 【PAT - 甲级1010】Radix (25分)(二分,进制转化)
  6. 【Elasticsearch】如何使用 Elasticsearch 6.2 搜索中文、日文和韩文文本 - 第 1 部分: 分析工具
  7. android make 编译器,Android make 基础
  8. Telegram纸飞机最大的电报中文搜索引擎Telegram中文交流社区
  9. jieba 同义词_jieba分词详解
  10. 最好的python视频教程_比较好的python视频教程
  11. 计算机Excel及格率怎么,及格率怎么算在excel里?
  12. 从TCL的40年变革史,看中国制造之路
  13. 蘑菇街iOS客户端应用源码
  14. 微信小程序实现评论多级展开收起以及点赞功能
  15. java分流什么意思_Flink如何分流数据
  16. 如何在共享中添加计算机,如何在网上邻居中添加共享文件夹
  17. laravel框架搭建voyager
  18. 致力做中产家庭亲子生活专家,爸妈营获宝宝树战略投资...
  19. AlarmManager
  20. 在基金重仓股中随机选股策略

热门文章

  1. 西门子200系列PLC通信编程指令讲解
  2. 【洛谷4920】[WC2015] 未来程序(提答题)
  3. 传奇手游服务器搭建_复古传奇手游服务端架设教程
  4. oracle 此处不允许序号
  5. SSL常见错误及解决方法
  6. 解决问题就像剥洋葱,解决的关键是基础知识
  7. openGL之API学习(五十五)凹凸贴图技术
  8. BAT在互联网医疗的产业布局分析
  9. 轻量级自动化测试框架 UFT 初学者 学习编写
  10. matlab如何设置自变量,matlab中如何指定一个函数的自变量