M3TILE - LATGACH3

In how many ways can you tile a 3×n rectangle with 2×1 dominoes?

Here is a sample tiling of a 3×12 rectangle.

Input consists of several test cases followed by a line containing -1. Each test case is a line containing an integer 0 ≤ n ≤ 30. For each test case, output one integer number giving the number of possible tilings.

Example

Input:
2
8
12
-1

Output:
3
153
2131

Được gửi lên bởi:psetter
Ngày:2009-02-17
Thời gian chạy:0.600s
Giới hạn mã nguồn:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Ngôn ngữ cho phép:Tất cả ngoại trừ: ERL GOSU JS-RHINO NODEJS PERL6 PYPY RUST SED VB.NET
Nguồn bài:ACM

hide comments
2021-05-27 18:02:09
Tham khảo: https://vnspoj.github.io/problems/M3TILE
2021-01-04 15:11:13
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll mem[31];

signed main()
{
mem[0]=1;
mem[1]=0;
mem[2]=3;
mem[4]=11;
for(int i=6; i<=30; ++i)
if(i%2==0)
{
int cnt=2;
for(int j=i-2; j>=0; j-=2,cnt+=2)
mem[i]+=mem[j]*cnt;
++mem[i];
}
int n;
while(cin>>n)
{
if(n==-1)
break;
cout<<mem[n]<<'\n';
}
}
Cách mới lạ cho ae nào cần. : DDD
2020-03-24 13:07:04
bài giới hạn 30 nhưng mọi người đừng giới hạn mảng 30 nha :))
2019-01-17 10:17:46
1 đấm AC.
2018-06-29 11:50:43
Xem code:
https://vietcodes.github.io/code/146/
2018-01-10 13:35:33
code cho ae nào cần
f[0][5]=1;
for(int i=1;i<=30;i++)
{
f[i][1]=f[i-1][2];
f[i][2]=f[i-1][1]*2+f[i-1][3]+f[i-1][5]*2;
f[i][3]=f[i-1][2];
f[i][4]=f[i-1][1]+f[i-1][5];
f[i][5]=f[i-1][4];
}
while(cin>>n)
{
if(n!=-1)cout<<f[n][1]+f[n][5]<<endl;
}
2017-11-24 03:47:18
0 ghi ra 1 :))) quỳ thánh cho test bóp vãi
2017-07-28 10:14:47
Bài này làm như đéo...Bực mìh
2016-12-15 09:02:56
1,0,3,0,11,0,41,0,153,0,571,0,2131,0,7953,0,29681,0,110771,0,413403,0,1542841,0,5757961,0,21489003,0,80198051,0,299303201

:))
2015-07-10 05:08:40 Bee
bài khó
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.