我的代码在我的平台上运行正常,但是在UVa上出现运行时错误。 链接到问题787:https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=0&problem=728&mosmsg=Submission+received+with+ID+23495958
我一直在寻找诸如除以0
之类的错误,但找不到任何东西。
https://pastebin.com/YeC1S7Rf
//BigInt library from https://github.com/NaimHasanPappu/Algorithm/blob/master/BigInteger.cpp
int id;
Int a[105];
Int ma;
Int z=Int(0);
Int one=Int(1);
Int pd;
Int firstne;
int idfirst;
int sol()
{
if(pd<z && idfirst<id)
{
pd/=firstne;
if(pd>ma) ma=pd;
idfirst=200;
}
}
int main()
{
ios_base::sync_with_stdio(false);
int t;
while(1)
{
pd=one;
bool f=1;
bool ne=1;
id=-1;
idfirst=200;
while(cin>>t)
{
++id;
if(t==-999999) break;
if(t==0)
{
f=0;
if(z>ma) ma=z;
if(id>1) sol();
pd=one;
id=-1;
ne=1;
}
else
{
a[id]=Int(t);
if(f) {ma=a[id]; f=0;}
pd*=a[id];
if(pd<z && ne)
{
firstne=pd;
idfirst=id;
ne=0;
}
if(pd>ma) ma=pd;
}
}
if(f) break;
if(id>1) sol();
cout<<ma<<endl;
}
return 0;
}