传送门

考虑一块块填,首先 $(1,1)$ 有 $4$ 种方案

然后根据 $(1,1)$ 的右边颜色,$(1,2)$ 有两种方案,$(1,3)$ 根据 $(1,2)$ 也有两种方案...

考虑 $(2,1)$ 根据 $(1,1)$ 有两种方案,$(3,1)$ 也有两种....

然后发现,如果我们确定了 $(1,1)$ 到 $(1,m)$ ,确定了 $(1,1)$ 到 $(n,1)$ ,那么之后所有位置都可以根据它们的左边颜色和上面颜色确定

那么方案数即为填左边一列和上边一行的方案数

那么答案整理一下就是 $2^{n+m}$

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
typedef long long ll;
inline int read()
{
int x=,f=; char ch=getchar();
while(ch<''||ch>'') { if(ch=='-') f=-; ch=getchar(); }
while(ch>=''&&ch<='') { x=(x<<)+(x<<)+(ch^); ch=getchar(); }
return x*f;
}
const int mo=;
int n,m;
inline int ksm(int x,int y)
{
int res=;
while(y) { if(y&) res=1ll*res*x%mo; x=1ll*x*x%mo; y>>=; }
return res;
}
int main()
{
n=read(),m=read();
printf("%d\n",ksm(,n+m));
return ;
}

最新文章

  1. IE6/7下空div占用空间的问题
  2. Elasticsearch集群配置以及REST API使用
  3. 【转】Unity3D中Layers和LayerMask解析
  4. php-fpm 启动不了 libiconv.so.2找不到
  5. 未定义标识符_ConnectionPtr
  6. python实用函数
  7. Word01-从正文处开始插入页码
  8. iOS-容易造成循环引用的三种场景
  9. 201521123030 《Java程序设计》 第9周学习总结
  10. LCD正向扫描和反向扫描
  11. 浅谈RabbitMQ Management
  12. 瞧一瞧!这儿实现了MongoDB的增量备份与还原(含部署代码)
  13. EO bugs
  14. MYSQL ini 配置文件详解及性能优化方案
  15. 【Dubbo 源码解析】06_Dubbo 服务调用
  16. Python基础学习(四)
  17. scrollview滑动到某区域执行某种方法
  18. const_cast, dynamic_cast, static_cast,reinterpret_cast
  19. ab压测工具
  20. Uva442

热门文章

  1. python如何实现一个类似重载的功能
  2. 朴素贝叶斯文本分类-在《红楼梦》作者鉴别的应用上(python实现)
  3. Maven-指定要打包的文件
  4. el-mement表单校验-校验失败时自动聚焦到失败的input框
  5. Mac 下 Android Studio 连 夜神模拟器 调试
  6. Windows10 修改键位映射
  7. Java语言 List 和 Array 相互转换
  8. JavaScript DOM 编程艺术(第二版) 初读学习笔记
  9. 2019CVPR:Classification-Reconstruction Learning for Open-Set Recogition(Abstract)
  10. 解决 nw 报错 net::ERR_UNSAFE_PORT