MBEEWALK - Bee Walk

A bee larva living in a hexagonal cell of a large honey comb decides to creep for a walk. In each “step” the larva may move into any of the six adjacent cells and after n steps, it is to end up in its original cell.

Your program has to compute, for a given n, the number of different such larva walks.

Input

The first line contains an integer giving the number of test cases to follow. Each case consists of one line containing an integer n, where 1 ≤ n ≤ 14.

Output

For each test case, output one line containing the number of walks. Under the assumption 1 ≤ n ≤ 14, the answer will be less than 2^31.

Input:
2
2
4

Output:
6
90


Được gửi lên bởi:psetter
Ngày:2009-02-24
Thời gian chạy:1s
Giới hạn mã nguồn:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Ngôn ngữ cho phép:ADA95 ASM32 BASH BF C CSHARP CPP C99 CLPS LISP sbcl LISP clisp D FORTRAN HASK ICON ICK JAVA LUA NEM NICE OCAML PAS-GPC PAS-FPC PERL PHP PIKE PRLG-swi PYTHON RUBY SCM guile SCM qobi ST WHITESPACE

hide comments
2021-05-27 18:01:39
Tham khảo: https://vnspoj.github.io/problems/MBEEWALK
2017-11-06 10:42:12
nhật hào sạch


Last edit: 2017-11-07 15:06:18
2016-12-12 15:32:50
var i, t : longint;
n : array[1..100] of longint;
f : array[2..14] of int64 = (6,12,90,360,2040,10080,54810,290640,1588356,8676360,47977776,266378112,1488801600);
begin
readln(t);
for i := 1 to t do readln(n[i]);
for i := 1 to t do writeln(f[n[i]]);
end.

Copy and Paste :)))

Last edit: 2016-12-12 15:33:47
2016-12-12 15:00:37
1: 0
2: 6
3: 12
4: 90
5: 360
6: 2040
7: 10080
8: 54810
9: 290640
10: 1588356
11: 8676360
12: 47977776
13: 266378112
14: 1488801600

Last edit: 2016-12-12 15:30:29
2015-06-14 16:07:04 [Nghien] Le Long
Ai cho xin cái mảng hằng nào
2014-06-19 17:21:16 Lollipop
1 đấm AC
2013-09-22 14:35:45 DKM
răng 4 lại ra 90 đc. ai giải thích hộ cái

Last edit: 2013-09-22 14:46:22
2009-12-27 11:55:05 chuottui
các anh chỉ cho em cái thuật toán cái nè
2009-04-13 22:41:10 dhkhtn
http://www.cs.sunysb.edu/~skiena/392/lectures/week12/ - toa do tam/luc giac
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.