Codeforces 1178C. Tiles
2024-10-06 23:36:51
考虑一块块填,首先 $(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 ;
}
最新文章
- IE6/7下空div占用空间的问题
- Elasticsearch集群配置以及REST API使用
- 【转】Unity3D中Layers和LayerMask解析
- php-fpm 启动不了 libiconv.so.2找不到
- 未定义标识符_ConnectionPtr
- python实用函数
- Word01-从正文处开始插入页码
- iOS-容易造成循环引用的三种场景
- 201521123030 《Java程序设计》 第9周学习总结
- LCD正向扫描和反向扫描
- 浅谈RabbitMQ Management
- 瞧一瞧!这儿实现了MongoDB的增量备份与还原(含部署代码)
- EO bugs
- MYSQL ini 配置文件详解及性能优化方案
- 【Dubbo 源码解析】06_Dubbo 服务调用
- Python基础学习(四)
- scrollview滑动到某区域执行某种方法
- const_cast, dynamic_cast, static_cast,reinterpret_cast
- ab压测工具
- Uva442
热门文章
- python如何实现一个类似重载的功能
- 朴素贝叶斯文本分类-在《红楼梦》作者鉴别的应用上(python实现)
- Maven-指定要打包的文件
- el-mement表单校验-校验失败时自动聚焦到失败的input框
- Mac 下 Android Studio 连 夜神模拟器 调试
- Windows10 修改键位映射
- Java语言 List 和 Array 相互转换
- JavaScript DOM 编程艺术(第二版) 初读学习笔记
- 2019CVPR:Classification-Reconstruction Learning for Open-Set Recogition(Abstract)
- 解决 nw 报错 net::ERR_UNSAFE_PORT