博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
UVA 10359 Tiling
阅读量:7089 次
发布时间:2019-06-28

本文共 593 字,大约阅读时间需要 1 分钟。

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[] args) {
Scanner cin = new Scanner(System.in); BigInteger[] f = new BigInteger[260]; f[0] = new BigInteger("1"); f[1] = new BigInteger("1"); for(int i = 2; i <= 250; i ++) f[i] = f[i - 2].multiply(BigInteger.valueOf(2)).add(f[i - 1]); while(cin.hasNext()) {
int n = cin.nextInt(); System.out.println(f[n]); } } }

转载地址:http://bvfql.baihongyu.com/

你可能感兴趣的文章
Ubuntu16.10安装Ocata之2:Keystone
查看>>
IGMPv3
查看>>
ZeroMQ(java)之Router/Dealer模式
查看>>
Linux下的文件查找命令
查看>>
TCP/IP协议碎碎念
查看>>
django 将表数据通过API展示到页面上
查看>>
linux用户登录检测发送邮件提醒
查看>>
SQL Server FullText解决Like字句性能问题
查看>>
Ceph实验室:第五课:Ceph运维之换盘
查看>>
C++实践参考——复数类中的运算符重载
查看>>
【Spark Summit East 2017】为了乐趣和利润的全球扩张
查看>>
Rss订阅
查看>>
Mac - gdb配置
查看>>
Vuejs——(4)v-if、v-for
查看>>
让Spark成为你的瑞士军刀
查看>>
[LeetCode]--40. Combination Sum II
查看>>
ART世界探险(16) - 快速编译器下的方法编译
查看>>
多线程常用方法 sleep wait join等以及对锁的控制
查看>>
MPEG-DASH新功能白皮书翻译
查看>>
关于图片在内存中的大小(k或者M)
查看>>