| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 773 人关注过本帖
标题: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
快速回复:Adding Ones, Twos, and Threes
数据加载中...
 
   



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

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