标题:Adding Ones, Twos, and Threes
取消只看楼主
心剑菩提
Rank: 1
等 级:新手上路
帖 子:249
专家分:0
注 册:2007-5-17
 问题点数:0 回复次数:0 
Adding Ones, Twos, and Threes
Description

Integer 4 can be expressed as a sum of 1s, 2s, and 3s in seven different ways as follows:
1+1+1+1, (1)
1+1+2, (2)
1+2+1, (3)
2+1+1, (4)
2+2, (5)
1+3, (6)
3+1. (7)
Write a program that determines the number of ways in which a given integer can be expressed as a sum of 1s, 2s, and 3s. You may assume that the integer is positive and less than 36.


Input

The input consists of T test cases. The number of test cases (T ) is given in the first line of the input file. Each test case consists of an integer written in a single line.

Output

Print exactly one line for each test case. The line should contain an integer representing the number of ways.

Sample Input


3
4
7
10


Sample Output


7
44
274


Source
搜索更多相关主题的帖子: Adding Ones Threes Twos 
2008-03-06 14:06



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-202213-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.593180 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved