hdu 1297 Children’s Queue(高精度加法+情况分析+打表)

题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1297


题目大意:校长要给孩子们排队,要求不能有单独的女孩子站在最后,问,对于n个人(男女不限)的合法队列有多少。


解题思路:num[n] = num[i - 1] + num[ i - 2] + num[i - 4];

不懂的话介绍一篇:http://www.cnblogs.com/hong0220/archive/2013/03/21/2972803.html


模板连接:http://blog.csdn.net/keshuai19940722/article/details/10087993


int main() {
    int n;
    bign num[1005];
    num[0] = num[1] = 1;
    num[2] = 2;
    num[3] = 4;
    for (int i = 4; i <= 1000; i++)
	num[i] = num[i - 1] + num[i - 2] + num[i - 4];
    while (cin >> n) {
	num[n].put();
	cout << endl;
    }
    return 0;
}


原文地址:https://www.cnblogs.com/bbsno1/p/3271052.html