题目链接:

id=2506">http://poj.org/problem?id=2506

本题用的java解的。由于涉及到大数问题,假设对java中的大数操作不熟悉请点这儿:链接

思路:地推公式f[i]=f[i-1]+2*f[i-2]

code:

import java.math.*;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner cin=new Scanner(System.in);
BigInteger a[] = new BigInteger[300];
BigInteger b=new BigInteger("2");
a[0]=BigInteger.valueOf(1);
a[1]=BigInteger.valueOf(1);
a[2]=BigInteger.valueOf(3);
a[3]=BigInteger.valueOf(5);
int n; for(int i=3;i<=255;i++)
{
a[i]=a[i-1].add(a[i-2].multiply(b));
}
while(cin.hasNext())
{
n=cin.nextInt();
System.out.println(a[n]);
}
}
}

poj 2506 Tiling(java解法)的更多相关文章

  1. poj 2506 Tiling(递推 大数)

    题目:http://poj.org/problem?id=2506 题解:f[n]=f[n-2]*2+f[n-1],主要是大数的相加; 以前做过了的 #include<stdio.h> # ...

  2. POJ 2506 Tiling(递推+大整数加法)

    http://poj.org/problem?id=2506 题意: 思路:递推.a[i]=a[i-1]+2*a[i-2]. 计算的时候是大整数加法.错了好久,忘记考虑1了...晕倒. #includ ...

  3. POJ 2506 Tiling (递推 + 大数加法模拟 )

    Tiling Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7965   Accepted: 3866 Descriptio ...

  4. poj 2506 Tiling 递推

    题目链接: http://poj.org/problem?id=2506 题目描述: 有2*1和2*2两种瓷片,问铺成2*n的图形有多少种方法? 解题思路: 利用递推思想,2*n可以由2*(n-1)的 ...

  5. [ACM] POJ 2506 Tiling (递归,睑板)

    Tiling Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7487   Accepted: 3661 Descriptio ...

  6. POJ 2506 Tiling

    Tiling Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7437   Accepted: 3635 Descriptio ...

  7. poj 2506 Tiling(高精度)

    Description In how many ways can you tile a 2xn rectangle by 2x1 or 2x2 tiles? Here is a sample tili ...

  8. POJ 2506 Tiling dp+大数 水题

    大致题意:现有两种方块(1X2,2X2),方块数量无限制.问用这两种方块填满2Xn的矩阵的填法有多少种. 分析:通俗点说,找规律.专业化一点,动态规划. 状态d[i],表示宽度为i的填法个数. 状态转 ...

  9. poj 2506 Tiling(大数+规律)

    poj2506Tiling 此题规律:A[0]=1;A[1]=1;A[2]=3;--A[n]=A[n-1]+2*A[n-2];用大数来写,AC代码: #include<stdio.h> # ...

随机推荐

  1. 汕头市队赛 SRM 07 A 你的麻将会排序吗

    A 你的麻将会排序吗 SRM 07 曾经有过一些沉迷日麻的小孩纸,后来呀,他们都去寻找自己的世界了. kpm也是这样的小孩纸.他想有一只自动整理牌的机器.当麻将以给定的顺序进入机器时,通过机器的运转, ...

  2. md5 加解密

    using JGDJWeb.Model; using System; using System.Collections.Generic; using System.IO; using System.L ...

  3. JSP中include指令和include动作浅析

    一. JSP工作原理 JSP文件是一种Servlet,其工作方式是先部署源代码后编译为.class文件.JSP会在客户端第一次请求JSP文件时被编译成Servlet,由Servlet处理客户端的请求. ...

  4. 官网cocos2d

    http://cocos2d.spritebuilder.com/download           官网 https://github.com/cocos2d/cocos2d-spritebuil ...

  5. 函数atof,atoi,atol,strtod,strtol,strtoul 描述

    函数atof,atoi,atol,strtod,strtol,strtoul atof(将字串转换成浮点型数) 相关函数 atoi,atol,strtod,strtol,strtoul表头文件 #in ...

  6. UVA 753 A Plug for UNIX

    最大流解决 . 设置源点 0,连接所有设备(device) .设备-插头 -汇点 #include <map> #include <set> #include <list ...

  7. Sax解析xml及pull解析xml

    sax解析参考:http://www.iteye.com/topic/763895: 说明:测试时报空指针异常,未能读取到数据,关注Sax解析的过程及API即可: pull解析参考:http://ww ...

  8. json model 互转

    1.json转model TestModel tm = new TestModel();JavaScriptSerializer js = new JavaScriptSerializer();tm ...

  9. codeforces-526B

    题目连接:http://codeforces.com/contest/526/problem/B B. Om Nom and Dark Park time limit per test 1 secon ...

  10. Code+ A 晨跑【三个数的最小公倍数】

    时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 262144K,其他语言524288K64bit IO Format: %lld 题目描述 “无体育,不清华”.“每天锻炼一小时,健康工作 ...