ARM servers get Xen hypervisor support# PDA - 掌中宝
r*y
1 楼
大家好,我有一个coding的面试题, 求大家提供思路:
大意是: 有两种长短不一样的砖, 垒砌一面任意长宽的墙, 要求是上下两层不能有砖
缝相连,问有多少种砌法? 详细英文叙述见下。 我能用递归算出一层的所有可能的排
列数, 但是怎么有效的排除砖缝相连的情况呢?本人非计算机专业,求帮助!多谢
Your niece was given a set of blocks for her birthday, and she has decided
to build a panel using
3”×1” and 4.5”×1" blocks. For structural integrity, the spaces between
the blocks must not line up
in adjacent rows.
There are 2 ways in which to build a 7.5”×1” panel, 2 ways to build a 7.5
”×2” panel, 4 ways to
build a 12”×3” panel, and 7958 ways to build a 27”×5” panel. How many
different ways are there
for your niece to build a 48”×10” panel? The answer will fit in a 64-bit
integer. Write a program to
calculate the answer.
The program should be non-interactive and run as a single-line command which
takes two
command-line arguments, width and height, in that order. Given any width
between 3 and 48 that
is a multiple of 0.5, inclusive, and any height that is an integer between 1
and 10, inclusive, your
program should calculate the number of valid ways there are to build a wall
of those dimensions.
Your program’s output should simply be the solution as a number, with no
line-breaks or white
spaces.
Your program will be judged on how fast it runs and how clearly the code is
written. We will be
running your program as well as reading the source code, so anything you can
do to make this
process easier would be appreciated.
Send the source code and let us know the value that your program computes,
your program’s
running time, and the kind of machine on which you ran it.
大意是: 有两种长短不一样的砖, 垒砌一面任意长宽的墙, 要求是上下两层不能有砖
缝相连,问有多少种砌法? 详细英文叙述见下。 我能用递归算出一层的所有可能的排
列数, 但是怎么有效的排除砖缝相连的情况呢?本人非计算机专业,求帮助!多谢
Your niece was given a set of blocks for her birthday, and she has decided
to build a panel using
3”×1” and 4.5”×1" blocks. For structural integrity, the spaces between
the blocks must not line up
in adjacent rows.
There are 2 ways in which to build a 7.5”×1” panel, 2 ways to build a 7.5
”×2” panel, 4 ways to
build a 12”×3” panel, and 7958 ways to build a 27”×5” panel. How many
different ways are there
for your niece to build a 48”×10” panel? The answer will fit in a 64-bit
integer. Write a program to
calculate the answer.
The program should be non-interactive and run as a single-line command which
takes two
command-line arguments, width and height, in that order. Given any width
between 3 and 48 that
is a multiple of 0.5, inclusive, and any height that is an integer between 1
and 10, inclusive, your
program should calculate the number of valid ways there are to build a wall
of those dimensions.
Your program’s output should simply be the solution as a number, with no
line-breaks or white
spaces.
Your program will be judged on how fast it runs and how clearly the code is
written. We will be
running your program as well as reading the source code, so anything you can
do to make this
process easier would be appreciated.
Send the source code and let us know the value that your program computes,
your program’s
running time, and the kind of machine on which you ran it.