用C++编程Number of Locks

来源:百度知道 编辑:UC知道 时间:2024/06/03 19:30:48
Description

In certain factory a kind of spring locks is manufactured. There are n slots (1 < n < 17, n is a natural number.) for each lock. The height of each slot may be any one of the 4 values in{1,2,3,4}( neglect unit ). Among the slots of a lock there are at least one pair of neighboring slots with their difference of height equal to 3 and also there are at least 3 different height values of the slots for a lock. If a batch of locks is manufactured by taking all over the 4 values for slot height and meet the two limitations above, find the number of the locks produced.
Input

There is one given data n (number of slots) on every line. At the end of all the input data is -1, which means the end of input.
Output

According to the input data, count the number of locks. Each output occupies one line. Its fore part is a repetition of the input data and then followed by a colon and a space. The last part of it is the number of the locks coun

题目的意思是让我们输入
slot的数目用-1 结束输入
并且输出满足条件的锁的数目
要求是:
1 至少要有一对相邻的slot高度差等于3
2 必须至少使用三个高度值
3 slot数目1<slot<17
4 slot的高度属于集合{1,2,3,4}

公式我写不出来

给答案给你 网上搜的

http://hi.baidu.com/scaneelingg/blog/item/fd173832bd4fbbff1a4cffef.html