Luo Gu P1968 dollar

Topic Portal

Problem-solving ideas:

A very simple DP

AC Code:

. 1 #include <the iostream>
 2 #include <cstdio>
 . 3  
. 4  the using  namespace STD;
 . 5  
. 6  int n-;
 . 7  Double WL [ 101 ], F [ 101 ] [ 2 ];
 . 8  // F [I] [0] represents i can be obtained the maximum number of days marks
 . 9  // F [i] [. 1] denotes the i-th day number can be obtained up to $ 
10  
. 11  int main () {
 12 is      Scanf ( " % D " , & n-);
 13 is      for ( int i = . 1 ; I <= n-; I ++ )
 14         scanf("%lf",&wl[i]);
15     f[1][0] = 100;//dollar
16     f[1][1] = wl[1];//mark
17     for(int i = 2;i <= n; i++)
18         for(int j = 1;j <= i; j++) {
19             f[i][0] = max(f[i][0],max(f[j][0],f[j][1] / wl[i] * 100));
20             f[i][1] = max(f[i][1],max(f[j][1],f[j][0] * wl[i] / 100));
21         }
22     printf("%.2lf",f[n][0]);
23     return 0;
24 }

 

Guess you like

Origin www.cnblogs.com/lipeiyi520/p/11986337.html