C 求助 为什么通不过?

P1015 [NOIP1999 普及组] 回文数

sonder236 @ 2022-10-19 17:11:52

#include <stdio.h>
#include <math.h>
int panhui(int shu);

int main()
{
    int n,m;
    int hui=0,shi=0;
    scanf("%d%d",&n,&m);
    int t;
    int count=0;
    t=m;
    int wei=1;
    for(;m>0;)
    {
        m=m/10;
        count++;
    }
    m=t;
    for(;count>0;count--)
    {

        shi=shi+m%10*wei;
        wei=wei*n;
        m=m/10; 
    }
    t=shi;
    int step=0;
    int iskey=0;
    for(;iskey==0&&step<=30;)
    {
        step++;
        t=shi;
        for(;shi>0;)
        {
            hui=hui*10+shi%10;
            shi=shi/10;
        }
        shi=t;
        int he;
        he=shi+hui;
        shi=he; 
        hui=0;
        if(panhui(he)==1)
        {
            iskey=1;
        }

    }
    if(step<=30)
    {
        printf("STEP=%d\n",step);
    }
    else
    {
        printf("Impossible!\n");
    }
    return 0;
}

int panhui(int shu)
{
    int p=0;
    int b;
    b=shu;
    for(;shu>0;)
    {
        p=p*10+shu%10;
        shu=shu/10;
    }
    shu=b;
    if(p==shu)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

|