# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
884588 | kokoue | Odd-even (IZhO11_oddeven) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
void clean(string &s)
{
int sz=s.size();
int i=0;
while(i<sz&&s[i]=='0')i++;
if(i==sz) s="0";
else
{
s=s.substr(i,sz-i);
}
}
int equalSize(string &s1,string &s2)
{
int sz1=s1.size(),sz2=s2.size();
int max_sz=sz1;
if(sz1<sz2)
{
int diff=sz2-sz1;
max_sz=sz2;
for(int i=0;i<diff;i++)
{
s1='0'+s1;
}
}
if(sz2<sz1)
{
int diff=sz1-sz2;
max_sz=sz1;
for(int i=0;i<diff;i++)
{
s2='0'+s2;
}
}
return max_sz;
}
string sumbig(string s1,string s2)
{
int summ,rem=0;
char c;
string result="";
int max_sz=equalSize(s1,s2);
for(int i=max_sz-1;i>=0;i--)
{
summ=(s1[i]-'0')+(s2[i]-'0')+rem;
rem=summ/10;
c=summ%10+'0';
result=c+result;
}
if(rem) result='1'+result;
return result;
}
string diff(string s1,string s2)
{
int sz1=s1.size(),sz2=s2.size(),lamp,rem=0,diff;
string result;
char c;
if((sz2>sz1) || (sz1==sz2 && s1<s2))
{
swap(s1,s2);
lamp=1;
}
int max_sz=equalSize(s1,s2);
for(int i=max_sz-1;i>=0;i--)
{
diff=(s1[i]-'0'-rem)-(s2[i]-'0');
rem=0;
if(diff<0){diff+=10;rem=1;}
c=diff+'0';
result=c+result;
}
clean(result);
return result;
}
string multy(string s,int dig)
{
int sz,max_sz,mult,rem=0;
sz=s.size();
string result;
string c;
if(dig)
{
for(int i=sz-1;i>=0;i--)
{
mult=(s[i]-'0')*dig+rem;
rem=mult/10;
c=mult%10+'0';
result=c+result;
}
if(rem>0){c=rem+'0';result=c+result;}
}
else result="0";
return result;
}
bool cmpBig(string s1,string s2)
{
int sz1=s1.size(),sz2=s2.size();
if(sz1>sz2) return true;
if(sz1==sz2)
{
if(s1>s2) return true;
}
return false;
}
bool cmpBig2(string s1,string s2)
{
int sz1=s1.size(),sz2=s2.size();
if(sz1>sz2) return true;
if(sz1==sz2)
{
if(s1>s2) return true;
if(s1==s2) return true;
}
return false;
}