为什么compile error?

P1307 [NOIP2011 普及组] 数字反转

火星大王 @ 2016-09-27 18:11:46

#include <iostream>
#include <cstring>
using namespace std;
char a[10000000000];
int b=0;
int y=0;
int main()
{
    //freopen("1307.in","r",stdin);
    cin>>a;
    if(a[b]=='-')
    {    
        cout<<"-";
        b++;
    }
    for(long long int c=strlen(a)-1;c>=b;c--)
    {
        if(a[c]!='0'||y==1)
        {
            cout<<a[c];
            y=1;
        }
    }
}
本地可以过但网站过不了

by 火星大王 @ 2016-09-27 18:16:45

/tmp/ccdRWc0r.o: In function `main':

tmpvf5rn3wo.cpp:(.text+0x19): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccdRWc0r.o

tmpvf5rn3wo.cpp:(.text+0x3b): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccdRWc0r.o

tmpvf5rn3wo.cpp:(.text+0x44): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccdRWc0r.o

tmpvf5rn3wo.cpp:(.text+0x6f): relocation truncated to fit: R_X86_64_PC32 against symbol `y' defined in .bss section in /tmp/ccdRWc0r.o

tmpvf5rn3wo.cpp:(.text+0x96): relocation truncated to fit: R_X86_64_PC32 against symbol `y' defined in .bss section in /tmp/ccdRWc0r.o

tmpvf5rn3wo.cpp:(.text+0xa5): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccdRWc0r.o

/tmp/ccdRWc0r.o: In function `__static_initialization_and_destruction_0(int, int)':

tmpvf5rn3wo.cpp:(.text+0xd6): relocation truncated to fit: R_X86_64_32 against `.bss'

tmpvf5rn3wo.cpp:(.text+0xe5): relocation truncated to fit: R_X86_64_32 against `.bss'

collect2: error: ld returned 1 exit status

这是错误


by 冯豫川555 @ 2016-09-27 18:47:59

你的数组太大了。。


by tqqpt @ 2016-09-27 19:00:10

1e10?!!! 数组太大


by 1124828077ccj @ 2016-09-27 19:29:46

@李俊彦 数组最多也就只能开到差不多10000000(7个0)而已


by 1124828077ccj @ 2016-09-27 19:30:32

所以就爆了


by 冯豫川555 @ 2016-09-27 21:11:25

128M=3200 0000 大小的int类数组,我真的不知道100亿本地是怎么过的


by 1jia1 @ 2016-09-27 21:31:54

洛谷一位数组最多七位数,二维10000(亲测)


by 火星大王 @ 2016-09-27 21:48:29

谢谢,已过


|