vs上正常,但提交编译错误

P1015 [NOIP1999 普及组] 回文数

azaz111 @ 2024-11-13 16:28:38

vs上运行的好好的,怎么一提交就编译错误

#include<iostream>
using namespace std;
#include<cstring>
#include<string>
#include<string.h>
int m[100000],b[1000000];
int len;
void  cun(string s1)
{
    for (int i = 0; i <s1.size(); i++)
    {
        if (s1[i] <= '9' && s1[i]>='0')
        {
            m[s1.size() - i] = s1[i]-'0';
        }
        else
        {
            m[s1.size() - i] = s1[i] - 'A'+10;
        }
    }
    /*for (int i = 1; i <= s1.size(); i++)
    {
        cout << m[i];
    }*/
}
void fan(int a[])
{
    for (int i = 1; i <= len; i++)
    {
        b[len + 1 - i] = a[i];
    }
}
void pplus(int a[],int b[],int n)
{
    for (int i = 1; i <= len; i++)
    {
        a[i] += b[i];
        a[i + 1] += a[i] / n;
        a[i] %= n;
    }
    if (a[len + 1])
    {
        len++;
    }
}
bool judge(int a[])
{
    string s,ss;
    for (int i = 1; i <= len; i++)
    {
        s+=to_string(a[i]);//啊啊啊啊?

    }
    ss = s;
    reverse(s.begin(), s.end());
    if (ss == s)return 1;
    else return 0;
}

int main()
{
    string s1;
    int n;
    cin >> n>> s1;
    cun(s1);
    len = s1.size();
    int v = 0;
    while (!judge(m))
    {
        fan(m);
        pplus(m, b, n);
        v++;
        if (v > 30)
        {
            break;
        }
    }
    if (v > 30)
    {
        cout<<"Impossible!";
    }
    else
    {
        cout <<"STEP="<< v;
    }

    return 0;
}

by zsfzhjf @ 2024-11-13 16:43:42

没加 algorithm 头文件。。。


by azaz111 @ 2024-11-13 18:02:48

@zsfzhjf 谢谢你!加上之后就过了!但我找了半天都没找到哪里需要algorithm呀。难道是洛谷不支持string头文件吗?


by zsfzhjf @ 2024-11-13 18:05:31

@azaz111 reverse 函数是在 algorithm 头文件里的


by azaz111 @ 2024-11-13 18:10:09

@zsfzhjf ok谢谢,vs里reverse也包含在string头文件里了,那看来应该是这有差异


|