1 条题解

  • 0
    @ 2025-9-9 23:46:55

    C :

    #include <stdio.h>
    int main(){
        int i, kase, n, S[41]={0, 0, 1, 2};
        scanf("%d", &kase);
        for(i=4; i<41; i++) S[i]=S[i-1]+S[i-2];
        while(kase--&&scanf("%d", &n))
            printf("%d\n", S[n]);
        return 0;
    }
    

    C++ :

    #include<stdio.h>
    int main()
    {
        int n;
        scanf("%d",&n);
        while(n--)
        {
            int m,i,f=0,s=1,t;
            scanf("%d",&m);
            for(i=1;i<m;i++)
            {
                t=f;
                f=s;
                s=t+s;
            }
            printf("%d\n",s);
        }
        return 0;
    }
    
    
    • 1

    信息

    ID
    1122
    时间
    3000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者