Codeforces 1178C. Tiles
考虑一块块填,首先 $(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 ;
}
Codeforces 1178C. Tiles的更多相关文章
- Codeforces 1500D - Tiles for Bathroom(贪心+队列)
Codeforces 题面传送门 & 洛谷题面传送门 首先先讲一发我的 \(n^2q\log n\) 的做法,虽然没有付诸实现并且我也深知它常数巨大过不去,但是我还是决定讲一讲(大雾 考虑设 ...
- @codeforces - 1214H@ Tiles Placement
目录 @description@ @solution@ @part - 1@ @part - 2@ @accepted code@ @details@ @description@ 给定一个 n 点的树 ...
- Codeforces Round #292 (Div. 1) B. Drazil and Tiles 拓扑排序
B. Drazil and Tiles 题目连接: http://codeforces.com/contest/516/problem/B Description Drazil created a f ...
- CodeForces - 516B Drazil and Tiles(bfs)
https://vjudge.net/problem/CodeForces-516B 题意 在一个n*m图中放1*2或者2*1的长方形,问是否存在唯一的方法填满图中的‘.’ 分析 如果要有唯一的方案, ...
- Codeforces Round #292 (Div. 1) B. Drazil and Tiles (类似拓扑)
题目链接:http://codeforces.com/problemset/problem/516/B 一个n*m的方格,'*'不能填.给你很多个1*2的尖括号,问你是否能用唯一填法填满方格. 类似t ...
- Codeforces Round #292 (Div. 1) - B. Drazil and Tiles
B. Drazil and Tiles Drazil created a following problem about putting 1 × 2 tiles into an n × m gri ...
- 【codeforces 516B】Drazil and Tiles
题目链接: http://codeforces.com/problemset/problem/516/B 题解: 首先可以得到一个以‘.’为点的无向图,当存在一个点没有边时,无解.然后如果这个图边双联 ...
- CodeForces 516B Drazil and Tiles 其他
原文链接http://www.cnblogs.com/zhouzhendong/p/8990658.html 题目传送门 - CodeForces 516B 题意 给出一个$n\times m$的矩形 ...
- Drazil and Tiles CodeForces - 516B (类拓扑)
Drazil created a following problem about putting 1 × 2 tiles into an n × m grid: "There is a gr ...
随机推荐
- Java String字符串的不可变
Java 通过把String类设计为final使类不可继承,将变量value设置为private并且是final的,且value没有setter方法,不可修改. 为什么这么设计: 1.字符串常量池的需 ...
- uniapp的微信小程序,获取授权,获取中文街道地理位置
w问题描述:在微信小程序模拟器上运行获取坐标时 获取不到信息,原因是 没有调起默认地理位置: 解决办法:或者在manifest.json的源码视图中配置:配置appid和地理位置 默认弹起获取地理位置 ...
- IDEA2019 JFormDesigner-6.0.6.2-intellij-idea破解版
IDEA2019 JFormDesigner-6.0.6.2-intellij-idea破解版 下载链接:百度云 提取码:10ox 下载完后通过idea的本地磁盘安装即可
- Angular5.0之 安装指定版本Angular CLI
我们可能会发现按照网上的方式下载安装后,使用Angular CLI生成的项目并不是我们想要的Angular的版本,因为在我们没有指定安装版本的前提下,默认会下载最新的版本安装,然而不同的Angular ...
- list元素按照日期排序
private static void ListSort(List<AppClassInfoVo> list) { Collections.sort(list, new Comparato ...
- Android res之shape
xml控件配置属性 android:background="@drawable/shape" 标签 corners ----------圆角gradient ----------渐 ...
- 理解Dubbo
1.Dubbo应用场景 2.Dubbo支持的协议 3.Dubbo性能比较 4.负载均衡策略 5.容错方案 6.Dubbo vs SpringCloud 7.深入Dubbo需要的技能
- iOS 应用"无法安装应用程序 因为证书无效"的解决方案
原因是由于iOS7.1要安装企业应用,url必须是https的,不能是http,这就要求我们的服务器要支持https.因此,只要将原链接: itms-services://?action=downlo ...
- Java语言实现 Base64 加密 & 解密
Java语言实现 Base64 加密 & 解密 Base64是网络上最常见的用于传输8Bit字节码的编码方式之一,Base64就是一种基于64个可打印字符来表示二进制数据的方法. Base64 ...
- makeObjectsPerformSelector的使用
NSArray 类定义的方法: makeObjectsPerformSelector:这是数组用的方法,类似于for循环. makeObjectsPerformSelector:@selector(m ...