自测一切数据正常,提交无法通过任何案例

P1015 [NOIP1999 普及组] 回文数

omegalpha @ 2024-11-27 23:07:40

#include<stdio.h>
#define s1 (STEP+1)%2
#define s0 STEP%2
int main()
{
    int N,a[2][100]={0},STEP=0;
    char M[100];
    int i=-1,x,y,k;
    scanf("%d\n",&N);
    do{
        scanf("%c",&M[++i]);
    }while(M[i]!='\n');
    y=i-1;
    while(i>=0){
        if(M[i]>='a')
            a[0][i]=M[i]-'a'+10;
        else if(M[i]>='A')
            a[0][i]=M[i]-'A'+10;
        else
            a[0][i]=M[i]-'0';
        i--;
    }
    while(STEP<30){
        i=y;
        for(x=0;x<=i/2;x++)
            if(a[s0][x]!=a[s0][i-x])
                break;
        if(x>i/2)
        {
            printf("STEP=%d",STEP);
            return 0;
        }
        x=y=a[s1][0]=0;
        do{
            a[s1][y]+=a[s0][i-x]+a[s0][x];
            k=a[s1][y]/N;
            a[s1][y]%=N;
            a[s1][++y]=k;
            x++;
        }while(x<=i);

        if(!a[s1][y])
            y--;
        //printf("%d=",STEP);for(x=0;x<=y;x++)printf("%d ",a[s1][x]);printf("\n");
        STEP++;
        }
    printf("Impossible!");
}

by omegalpha @ 2024-11-27 23:09:35

求原因


|