Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- float dp[101][601];
- int main()
- {
- int n,a,b;
- cin>>n>>a>>b;
- for(int j=1;j<=6;++j)
- dp[1][j]=1/6.0;
- float s;
- for(int i=2;i<=n;++i)
- for(int j=1;j<=6*n;++j)
- {
- s=0.0;
- int Min=min(j-1,6);
- for(int k=1;k<=Min;++k)
- s+=dp[i-1][j-k],
- dp[i][j]=s/6.0;
- }
- s=0.0;
- for(int j=a;j<=b;++j)
- s+=dp[n][j];
- cout<<fixed<<setprecision(6)<<s<<'\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement