求大神查WA原因,快速幂通项An = An-1 + An-3 + 1
#include <stdio.h>

void Mutiply(unsigned int a[][3], unsigned int b[][3])
{
    unsigned int c[3][3];
    unsigned int i, j, k;
    for(i = 0; i < 3; i++)
    {
        for(j = 0; j < 3; j++)
        {
            unsigned int Q = 0;
            for(k = 0; k < 3; k++)
            {
                Q += a[i][k] * b[k][j];
                if(Q > 9973) Q %= 9973; /*Mode 9973*/
            }
            c[i][j] = Q;
        }
    }
    for(i = 0; i < 3; i++)
    {
        for(j = 0; j < 3; j++)
        {
            a[i][j] = c[i][j];
        }
    }
}
int main()
{
    int N;
    scanf(\"%d\", &N);
    unsigned int ans[3] = {3, 5, 7};
    if(N <= 3)
    {
        printf(\"%u\\n\", ans[N - 1] - 1);
        return 0;
    }
    /**********************/
    unsigned int TS[3][3] =
    {
        {1, 0, 0},
        {0, 1, 0},
        {0, 0, 1}
    };
    unsigned int FLT[3][3] =
    {
        {0, 0, 1},
        {1, 0, 0},
        {0, 1, 1}
    };
    unsigned int ci = N - 3;
    while(1)
    {
        if(ci & 0x1) Mutiply(TS,FLT);
        ci >>= 1;
        if(0 == ci) break;
        Mutiply(FLT,FLT);
    }
    ci = ans[0] * TS[0][2];
    ci += ans[1] * TS[1][2];
    ci += ans[2] * TS[2][2];
    /**********************/
    printf(\"%u\\n\", (ci + 9972) % 9973);
    return 0;
}
起码有好多语法错误啊 !
© 2015 HUST ACMICPC TEAM. All Right Reserved.