题意:求用1×2的棋子摆满n×m的棋盘的方案数。(n×m<=100)
#include <bits/stdc++.h>
using namespace std;
long long d[2][1<<10], n, m;
int main() {
while(~scanf("%d%d", &n, &m)) {
if(m>n) swa
原创
2021-08-11 14:47:44
86阅读
轮廓线DP。。。白书例
原创
2023-07-05 19:08:36
56阅读
$\color{ 0066ff}{ 题目描述 }$ 给定一个m×n的矩形网格,用1×2多米诺骨牌完全平铺。 请注意,即使一个平铺的旋转与另一个平铺相匹配,它们仍算作不同的平铺。 下面显示了一个平铺示例。 输入格式 输入包括多组数据。每组数据占一行,包含两个整数m,n(n×m≤100)。输入结束标志为
原创
2021-07-27 09:31:06
65阅读
题目链接:https://vjudge.net/problem/UVA-11270 题意: 用2*1的骨牌填满n*m大小的棋盘,问有多少种放置方式。 题解: 骨牌类的插头DP。 1.由于只需要记录轮廓线上m个位置的放置情况(0或1),且m<=10,2^10 = 1024,故可以用二进制对轮廓线的信息
转载
2017-12-04 21:21:00
95阅读
2评论
Til
原创
2022-08-11 15:10:47
82阅读
地址:http://poj.org/problem?id=2506递推公式::f[x]=f[x-1]+f[x-2]*2需要用到大数。 1 #include 2 #include 3 #define max 100 4 int f[500][max]; 5 int h[max]; 6 int main() 7 { 8 int n,j; 9 while(scanf("%d",&n)!=EOF)10 {11 if(n==0) {printf("1\n");continue;}12 memset(f,0,sizeof(f));13 ...
转载
2013-08-01 21:32:00
99阅读
2评论
HDU_2518
这个题目明显就是裸的Dancing Links,只不过由于情况实在太多了,写起来超级繁琐,而且写完之后几乎不可能在规定时间内出解(大家交的都是0ms的,估计都是打表交的),于是就只好把6种情况的结果存到数组里直接输出了。
View Code // 打表程序
#include<stdio.h>
#include<string.h>
#define
转载
2012-09-01 08:38:00
29阅读
2评论
F - Dominoes(贪心)思路:因为要使最大列1的个数最小,所以根据贪心思想,我们要尽可能地将1平摊每一列,因此我们优先对1的个数多进行放置,优先级:{11,01,10,00}\{11,01,10,00\}{11,01,10,00}我们先从左到右,从上到下放111111 ,然后再放010101或101010,因为要是每列平摊,所以这一行的两列放的010101,下一列如果有101010就...
原创
2022-01-22 14:58:28
39阅读
F - Dominoes(贪心)
思路:因为要使最大列1的个数最小,所以根据贪心思想,我们要尽可能地将1平摊每一列,因此我们优先对
1的个数多进行放置,优先级:{11,01,10,00}\{11,01,10,00\}{11,01,10,00}
我们先从左到右,从上到下放111111 ,然后再放010101或101010,因为要是每列平摊,所以这一行的两列放的010101,下一列如果有101010就...
原创
2021-08-10 09:36:02
16阅读
TilingTime Limit:1sMemory limit:32MAccepted Submit:197Total Submit:496In how many ways can you tile a 2xn rectangle by 2x1 or 2x2 tiles? Here is a sample til
原创
2021-08-20 15:05:37
72阅读
There are n dominoes in a line, and we place each domino vertically upright. In the beginning, we simultaneously push some of the dominoes either to t ...
转载
2021-07-22 06:29:00
77阅读
2评论
There are N dominoes in a line, and we place each domino vertically upright. In the beginning, we simultaneously push some of the dominoes either to t
转载
2019-03-22 21:04:00
52阅读
2评论
// 题意: 在一个2*n的矩形中放置2*2和2*1的矩形,问有多少种放置方法,方程 ans[b]=ans[b-1]+2*ans[b-2]#include <iostream>#include <string>using namespace std;int compare(string str1, string str2){ while(!str1.empty()&&str1[0]=='0') { str1.erase(0,1); } while(!str2.empty()&&str2[0]=='0') {
转载
2011-07-22 19:46:00
50阅读
TilingTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 7679 Accepted: 3734DescriptionIn how many ways can you tile a 2xn rectangle by 2x1 or 2x2 tiles?
原创
2023-04-20 21:45:29
55阅读
UVA_10359
我们令f(n)表示有n列时的放置种数,那么我们不妨考虑左边第一个位置如何放置。实际上一共有三种情况,这样就可以得到f(n)=f(n-1)+2*f(n-2)。
import java.math.BigInteger;import java.util.Scanner;public class Main {public static void main(String[] a
转载
2011-12-15 22:40:00
36阅读
2评论
水题,一个小模拟。规律也好找 f3 = f1 * 2 + f2; #include <iostream> #include <cstdlib> #include <cstdio> #include <cstring> #include <algorithm> const int INF = 1e8;
转载
2017-05-27 17:38:00
75阅读
2评论
Description
Input
Input is a sequence of lines, each line containing an integer numb...
原创
2022-12-07 14:19:27
39阅读
http://codeforces.com/contest/394/problem/C题意:有n*m个骨牌,每个骨牌上有四种样式(“01,10,11,00”),让你重新排列成一个N*M的矩阵,使2*m列的每一列和的最大值最小。思路:先排序,先正着排全是‘11’的牌,如果在一行,没有排满,用剩下的牌补...
转载
2015-01-27 10:13:00
53阅读
2评论
Find the number of ways to tile an m
原创
2022-08-10 14:36:45
77阅读
题目There are N dominoes in a line, and we place each domino vertically upright.In the beginning, we simultaneously push some of the dominoes either to the left or to the right.After each second, each d