hdu 2046 骨牌铺方格

http://acm.hdu.edu.cn/showproblem.php?pid=2046

这是一道递推题目,只要列举1到7就可以了,我们会发现:1-1,2-2,3-3,4-5,5-8,6-13,7-21。。。。。不过这里要小心50时定义时要用——int64

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#include <math.h>

int main()

{

    __int64 a[60];int n;

    a[1]=1;a[2]=2;

    for(__int64 i=3;i<=50;++i)

    a[i]=a[i-1]+a[i-2];

    while(scanf("%d",&n)!=EOF)

    printf("%I64d\n",a[n]);

  //  system("pause");

    return 0;

}

posted @ 2011-08-08 16:03  ○o尐懶錨o  阅读(300)  评论(0编辑  收藏  举报