p1018 乘積最大
一道dp題目。比較好像的dp題目。
然而他需要高精度計算。
所以,他從我開始學oi,到現在。一直是60分的狀態。
今天正打算複習模板。也就有藉口解決了這道題目。
#include#include#include#includeusing std::max;
using std::min;
const int maxn=100;
const long long base=1e7;
struct node
void exact()
void fill(char *a,int l,int r)
node operator + (const node &a)const
res.exact();
return res;
}node operator * (const node &a)const
res.exact();
return res;
}bool operator <(const node &a)const
};node base[41][41];
node f[41][41];
node a,b,c;
char data[50];
int main()
*/ for(int i=1;i<=s;i++)
for(int j=i;j<=s;j++)
base[i][j].fill(data,i,j);
for(int i=1;i<=s;i++)
f[i][0]=base[1][i];
for(int k1=1;k1<=k;k1++)
for(int i=k1;i<=s;i++)
for(int j=k1;jf[i][k1]=max(f[i][k1],f[j][k1-1]*base[j+1][i]);
f[s][k].print();
}
洛谷P1018 乘積最大 dp 高精度
題目大意 給定乙個 n 個數組成的串,可以在串中插入 m 個乘號,求乘積最大是多少。n 40 階段 前 i 個數用了 j 個乘號。僅用階段可以表示出乙個狀態,因此狀態轉移方程為 dp i j max 如下 include using namespace std const int maxn 50 s...
P1018 乘積最大
今年是國際數學聯盟確定的 2000 世界數學年 又恰逢我國著名數學家華羅庚先生誕辰90周年。在華羅庚先生的家鄉江蘇金壇,組織了一場別開生面的數學智力競賽的活動,你的乙個好朋友xz也有幸得以參加。活動中,主持人給所有參加活動的選手出了這樣一道題目 設有乙個長度為n的數字串,要求選手使用k個乘號將它分成...
P1018 乘積最大
今年是國際數學聯盟確定的 2000 世界數學年 又恰逢我國著名數學家華羅庚先生誕辰90周年。在華羅庚先生的家鄉江蘇金壇,組織了一場別開生面的數學智力競賽的活動,你的乙個好朋友xz也有幸得以參加。活動中,主持人給所有參加活動的選手出了這樣一道題目 設有乙個長度為n的數字串,要求選手使用k個乘號將它分成...