传送门

考虑一块块填,首先 $(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的更多相关文章

  1. Codeforces 1500D - Tiles for Bathroom(贪心+队列)

    Codeforces 题面传送门 & 洛谷题面传送门 首先先讲一发我的 \(n^2q\log n\) 的做法,虽然没有付诸实现并且我也深知它常数巨大过不去,但是我还是决定讲一讲(大雾 考虑设 ...

  2. @codeforces - 1214H@ Tiles Placement

    目录 @description@ @solution@ @part - 1@ @part - 2@ @accepted code@ @details@ @description@ 给定一个 n 点的树 ...

  3. 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 ...

  4. CodeForces - 516B Drazil and Tiles(bfs)

    https://vjudge.net/problem/CodeForces-516B 题意 在一个n*m图中放1*2或者2*1的长方形,问是否存在唯一的方法填满图中的‘.’ 分析 如果要有唯一的方案, ...

  5. Codeforces Round #292 (Div. 1) B. Drazil and Tiles (类似拓扑)

    题目链接:http://codeforces.com/problemset/problem/516/B 一个n*m的方格,'*'不能填.给你很多个1*2的尖括号,问你是否能用唯一填法填满方格. 类似t ...

  6. 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 ...

  7. 【codeforces 516B】Drazil and Tiles

    题目链接: http://codeforces.com/problemset/problem/516/B 题解: 首先可以得到一个以‘.’为点的无向图,当存在一个点没有边时,无解.然后如果这个图边双联 ...

  8. CodeForces 516B Drazil and Tiles 其他

    原文链接http://www.cnblogs.com/zhouzhendong/p/8990658.html 题目传送门 - CodeForces 516B 题意 给出一个$n\times m$的矩形 ...

  9. Drazil and Tiles CodeForces - 516B (类拓扑)

    Drazil created a following problem about putting 1 × 2 tiles into an n × m grid: "There is a gr ...

随机推荐

  1. 白鹭引擎EUI做H5活动 入门篇

    前言:本学习文档的目的是为了实现h5,或者简单的h5游戏,比如说,我们要实现一个可以左右,或者上下移动的场景的h5,在场景移动的过程中,会有相应的动画或者操作,我们通过 js 也可以实现,但是为了流畅 ...

  2. Windows环境下Zookeeper的安装和部署(单机模式和伪集群模式)

    第一部分:单机模式 1)下载地址:http://www.pirbot.com/mirrors/apache/zookeeper/,建议下载stable版本 2)解压缩 将下载好的压缩包解压到指定目录, ...

  3. 【python / mxnet / gluoncv / jupyter notebook】变换场景的同一行人多重识别

    程序环境为高性能集群:CPU:Intel Xeon Gold 6140 Processor * 2(共36核心)内存:512GB RAMGPU:Tesla P100-PCIE-16GB * 2   数 ...

  4. Windows下设置U盘自动复制文件到本地

    一.打开记事本,把下面的代码复制进去 set fso=createobject("scripting.filesystemobject") set ws=createobject( ...

  5. dnSpy PE format ( Portable Executable File Format)

    Portable Executable File Format PE Format  微软官方的 What is a .PE file in the .NET framework? [closed] ...

  6. Mac 下 Android Studio 连 夜神模拟器 调试

    1.运行夜神模拟器(自行搜索下载) 2.进入资源目录 cd /Applications/Nox\ App\ Player.app/Contents/MacOS 3.执行命令连接 adb connect ...

  7. HTML中meta=“viewport”的介绍

    viewport就是浏览器上用来显示网页的那部分区域 layout viewport:整个网页所占据的区域(包括可视也包括不可视的区域)  默认的 visual viewport:网页在浏览器上的可视 ...

  8. flutter 打包

    iOS打包 iOS打包需要注意一下一些设置 info.plist 设置ATS.白名单.字符串等等 Assets.xcassets 替换icon,替换LaunchImage中内容 注意LaunchIma ...

  9. visual studio 2019不能在vue文件中直接识别less语法

    试了好多方法,不象vs code那样能直接在template vue文件中就识别less语法下边这种分离的方式是可以的,在项目中也比较实用,将来你代码量大了,样式/脚本也还是要和template代码分 ...

  10. php文件上传系统

    一般10M以下的文件上传通过设置Web.Config,再用VS自带的FileUpload控件就可以了,但是如果要上传100M甚至1G的文件就不能这样上传了.我这里分享一下我自己开发的一套大文件上传控件 ...