Advertisement
a53

Zar2

a53
Jan 22nd, 2022 (edited)
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4. float dp[101][601];
  5. int main()
  6. {
  7. int n,a,b;
  8. cin>>n>>a>>b;
  9. for(int j=1;j<=6;++j)
  10. dp[1][j]=1/6.0;
  11. float s;
  12. for(int i=2;i<=n;++i)
  13. for(int j=1;j<=6*n;++j)
  14. {
  15. s=0.0;
  16. int Min=min(j-1,6);
  17. for(int k=1;k<=Min;++k)
  18. s+=dp[i-1][j-k],
  19. dp[i][j]=s/6.0;
  20. }
  21. s=0.0;
  22. for(int j=a;j<=b;++j)
  23. s+=dp[n][j];
  24. cout<<fixed<<setprecision(6)<<s<<'\n';
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement