```
BigNum BigNum::operator-(const BigNum & T) const //两个大数之间的相减运算
{
int i, j, big;
bool flag;
BigNum t1, t2;
if (*this > T)
{
t1 = *this;
t2 = T;
flag = 0;
}
else
{
t1 = T;
t2 = *this;
flag = 1;
}
big = t1.len;
for (i = 0; i < big; i++)
{
if (t1.a[i] < t2.a[i])
{
j = i + 1;
while (t1.a[j] == 0)
j++;
t1.a[j--]--;
while (j > i)
t1.a[j--] += MAXN;
t1.a[i] += MAXN + 1 - t2.a[i];
}
else
t1.a[i] -= t2.a[i];
}
t1.len = big;
while (t1.a[len - 1] == 0 && t1.len > 1)
{
t1.len--;
big--;
}
if (flag)
t1.a[big - 1] = 0 - t1.a[big - 1];
return t1;
}
BigNum BigNum::operator*(const BigNum & T) const //两个大数之间的相乘运算
{
BigNum ret;
int i, j, up;
int temp, temp1;
for (i = 0; i < len; i++)
{
up = 0;
for (j = 0; j < T.len; j++)
{
temp = a[i] * T.a[j] + ret.a[i + j] + up;
if (temp > MAXN)
{
temp1 = temp - temp / (MAXN + 1) * (MAXN + 1);
up = temp / (MAXN + 1);
ret.a[i + j] = temp1;
}
else
{
up = 0;
ret.a[i + j] = temp;
}
}
if (up != 0)
ret.a[i + j] = up;
}
ret.len = i + j;
while (ret.a[ret.len - 1] == 0 && ret.len > 1)
ret.len--;
return ret;
}
bool BigNum::operator>(const BigNum & T) const //大数和另一个大数的大小比较
{
int ln;
if (len > T.len)
return true;
else if (len == T.len)
{
ln = len - 1;
while (a[ln] == T.a[ln] && ln >= 0)
ln--;
if (ln >= 0 && a[ln] > T.a[ln])
return true;
else
return false;
}
else
return false;
}
bool BigNum::operator >(const int & t) const //大数和一个int类型的变量的大小比较
{
BigNum b(t);
return *this > b;
}
void BigNum::print() //输出大数
{
int i;
//cout << a[len - 1];
printf("%d", a[len - 1]);
for (i = len - 2; i >= 0; i--)
{
/*cout.width(DLEN);
cout.fill('0');
cout << a[i];*/
printf("%04d", a[i]);
}
//cout << endl;
printf("\n");
}
int n,m;
BigNum aa[100][100],f[100][100],p[100];
int main()
{
cin>>n>>m;
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
cin>>aa[i][j];
p[0]=1;
for(int i=1;i<=100;i++)
{
p[i]=p[i-1]*2;
}
BigNum ans=0;
for(int a=1;a<=n;a++)
{
memset(f,0,sizeof(f));
for(int i=1;i<=m;i++)
{
for(int j=m;j>=i;j--)
{
if(f[i-1][j]+aa[a][i-1]*p[m-(j-i+1)]>f[i][j+1]+aa[a][j+1]*p[m-(j-i+1)])
f[i][j]=f[i-1][j]+aa[a][i-1]*p[m-(j-i+1)];
else f[i][j]=f[i][j+1]+aa[a][j+1]*p[m-(j-i+1)];
}
}
BigNum Max = 0;
for(int i=1;i<=m;i++)
{
if(f[i][i]+aa[a][i]*p[m]>Max)
Max=f[i][i]+aa[a][i]*p[m];
}
ans=ans+Max;
}
ans.print();
}
```
by COUPDETAT @ 2019-09-14 17:39:25
__int128了解一下
by CreeperLordVader @ 2019-09-14 17:44:09
@[COUPDETAT](/space/show?uid=58064) __int128 ,你值得拥有!
by Alex_Wei @ 2019-09-14 17:44:58
@[COUPDETAT](/space/show?uid=58064) 您居然在家里做题,Orz
by noall @ 2019-09-14 17:49:33
~~抄的?代码相似度60%+警告~~
by XeCtera @ 2019-09-14 18:29:13
@[COUPDETAT](/space/show?uid=58064) 这题不用吧,__int128+手打快读快输完了
by 73EL @ 2019-09-14 18:50:54
@[HoneyLemon](/space/show?uid=38785) ~~大整数类直接粘的~~
by COUPDETAT @ 2019-10-21 15:42:22