My code works fine on my platform but got runtime error on UVa. Link to problem 787: https://onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=0&problem=728&mosmsg=Submission+received+with+ID+23495958
I've looked for errors like divide by 0 but can't find anything.
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;
}
Aucun commentaire:
Enregistrer un commentaire