Home > Back-end >  Dynamic programming LianCheng problem solving matrix
Dynamic programming LianCheng problem solving matrix

Time:09-18

Don't know where the error has been run out the results
Hope the great god give directions

#include
using namespace std;
# define the SIZE of 100
Void MatrixFun ()
{
Int n, p [SIZE], m [SIZE] [SIZE];
cin> n;
Memset (m, 0 x7f, sizeof (m));
for (int i=0; I & lt;=n; Cin i++) & gt;> P [I];
for (int i=0; I & lt;=n; I++) m [I] [I]=0;
For (int r=2; R & lt;=n; R++)
for (int i=0; I & lt;=n - r; I++)
{int j=I + r - 1;
For (int k=I; k <=j - 1; K++)
{
Int temp.
Temp=m [I] [k] [k + 1) + m + p [j] [I] * p * p (k + 1] [j + 1);
If (temp & lt; M [I] [j])
M [I] [j]=temp;
}
}
cout }
Int main ()
{
MatrixFun ();
system("pause");
return 0;
}

  • Related