Advertisement
ekzolot

Untitled

Sep 17th, 2022
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. int main(){
  5.     int n;
  6.     cin>>n;
  7.     vector <double> dp(n+1);
  8.     for (int i=1; i<=n; i++){
  9.         for (int j=1; j<=6; j++){
  10.             if ((1/12.0*((j+6)*(7-j))+1/6.0*(j-1)*dp[i-1])>dp[i]){
  11.                 dp[i]=1/12.0*((j+6)*(7-j))+1/6.0*(j-1)*dp[i-1];
  12.             }
  13.         }
  14.     }
  15.     cout<<dp[n]<<endl;
  16. }
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement