1 solutions

  • 0
    @ 2025-11-5 15:03:05

    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

    Information

    ID
    16370
    Time
    3000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By