题目链接:uva 10918 - Tri Tiling

题目大意:给出n,计算用1*2的瓷砖有多少种方法铺满3*n的地方。

解题思路:和uva 10359 - Tiling有点相似,不过难度会比较大,公式c[i] = 4 * c[i - 2] - c[i - 4].

推导过程:c[0] = 1, c[2] = 3, c[4] = c[2] * 3 + c[1] * 2, c[6] = c[4] * 3 + (c[0] + c[2]) * 2 ....

即c[i] = c[i - 2] * 3 + 2 *∑(0≤j≤-4) c[j], 然后带入前一项的公式可以化简成上面的公式。

#include <stdio.h>
#include <string.h>
#define ll long long ll n, c[35]; void init() {
memset(c, 0, sizeof(c));
c[0] = 1;
c[2] = 3;
for (int i = 4; i <= 30; i++)
c[i] = 4 * c[i - 2] - c[i - 4];
} int main() {
init();
while (scanf("%lld", &n), n!= -1) {
printf("%lld\n", c[n]);
}
return 0;
}

uva 10918 - Tri Tiling(规律)的更多相关文章

  1. Tri Tiling[HDU1143]

    Tri Tiling Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  2. Tri Tiling(hdu1143)

    Tri Tiling Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  3. POJ 2663 Tri Tiling

                                                                                    Tri Tiling   Time Li ...

  4. POJ 2663 Tri Tiling 矩阵快速幂 难度:3

    Tri Tiling Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7841   Accepted: 4113 Descri ...

  5. HDU 1143 Tri Tiling

    链接:http://acm.hdu.edu.cn/showproblem.php? pid=1143 Tri Tiling Time Limit: 2000/1000 MS (Java/Others) ...

  6. HDU 1143 Tri Tiling (递推)

    Tri Tiling Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total ...

  7. POJ 2663 Tri Tiling dp 画图找规律

    状态:d[i]代表n=i时的方案数. 状态转移方程:d[i]=d[i-2]+2*(d[i-2]+d[i-4]+-+d[0]) i只会为偶数,奇数情况不存在,d[0]=1 找状态转移方程的时候画图更好理 ...

  8. 【UVa】11270 Tiling Dominoes

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  9. I - Tri Tiling

      Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status #in ...

随机推荐

  1. Numpy array分割

    1.纵向分割 >>> import numpy as np >>> A = np.arange(12).reshape((3, 4)) >>> p ...

  2. linux基础编程:IO模型:阻塞/非阻塞/IO复用 同步/异步 Select/Epoll/AIO(转载)

      IO概念 Linux的内核将所有外部设备都可以看做一个文件来操作.那么我们对与外部设备的操作都可以看做对文件进行操作.我们对一个文件的读写,都通过调用内核提供的系统调用:内核给我们返回一个file ...

  3. iOS.Notification.Bar.Color

    Reference: http://apple.stackexchange.com/questions/44246/what-determines-the-special-color-of-the-s ...

  4. CentOS6.2网卡绑定配置

    下面主要介绍在CentOS6.2下使用系统自带的bonding进行网卡绑定的详细步骤,在此之前你可以看一下Linux网卡绑定探析,你也可以使用网卡绑定的脚本进行网卡绑定操作. 注意:请在配置前关闭Ne ...

  5. C单链表操作

    #include <stdio.h> #include <stdlib.h> #define ElemType int #define Status int #define O ...

  6. BZOJ4813或洛谷3698 [CQOI2017]小Q的棋盘

    BZOJ原题链接 洛谷原题链接 贪心或树形\(DP\)都可做,但显然\(DP\)式子不好推(因为我太菜了),所以我选择贪心. 很显然从根出发主干走最长链是最优的,而剩下的点每个都需要走两步,所以用除去 ...

  7. Mac 环境通用

    mac 下更新 .bash_profile 文件 1.打开terminal(终端) 2.cd ~ ( 进入当前用户的home目录) 3.open .bash_profile (打开.bash_prof ...

  8. Android Makefile中是 如何识别 TARGET_PRODUCT 的

    http://blog.csdn.net/stevenliyong/article/details/5285334 今天有时间小看一下Android 的Makefile, 终于稍有明白Android ...

  9. Reading CLR via c# 4th Edition

    In fact, at runtime, the CLR has no idea which programming language the developer used for thesource ...

  10. 棋盘问题(NOIP1997)

    题目链接:棋盘问题 这道题水不水呢?还是很水的,为什么?因为数据太小了.直接算就行了. #include<bits/stdc++.h> using namespace std; int m ...