Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define VERBOSE
- #define _USE_MATH_DEFINES
- #define _CRT_SECURE_NO_WARNINGS
- #include <algorithm>
- #include <fstream>
- #include <bitset>
- #include <cctype>
- #include <cfloat>
- #include <climits>
- #include <cmath>
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <ctime>
- #include <deque>
- #include <functional>
- #include <iomanip>
- #include <iostream>
- #include <list>
- #include <map>
- #include <numeric>
- #include <queue>
- #include <set>
- #include <sstream>
- #include <stack>
- #include <string>
- #include <vector>
- #ifndef _DEBUG
- # undef VERBOSE
- #endif
- #ifdef NDEBUG
- #define VERBOSE
- #endif
- #define eps 1e-8
- #define inf (1000 * 1000 * 1000)
- #define linf (4LL * 1000 * 1000 * 1000 * 1000 * 1000 * 1000)
- #define sqr(x) ((x) * (x))
- #define eq(x, y) (((x) > (y) ? (x) - (y) : (y) - (x)) <= eps)
- #define sz(x) int((x).size())
- #define all(x) (x).begin(), (x).end()
- #define rall(x) (x).rbegin(), (x).rend()
- #define mp make_pair
- #define FOR(i, n) for(int (i) = 0; (i) < (n); ++(i))
- #define FORN(i, n) for(int (i) = 1; (i) <= (n); ++(i))
- #define REP(i,from,to) for(int (i) = (from); (i) <= (to); ++(i))
- #define RREP(i,from,to) for(int (i) = (from); (i) >= (to); --(i))
- #define FOREACH(iter, cont) for(__typeof(cont)::iterator it = (cont).begin(); (it) != (cont).end(); ++(it))
- using namespace std;
- typedef unsigned uint;
- typedef long long llong;
- typedef unsigned long long ullong;
- typedef long double ldouble;
- typedef vector<int> vi;
- typedef vector<vi> vvi;
- typedef vector<double> vd;
- typedef vector<vd> vvd;
- struct debug_t {
- template <typename T>
- debug_t& operator<<(const T& value) {
- # ifdef VERBOSE
- cout << value;
- # endif
- return *this;
- }
- } debug;
- double dp[501][3001]; // dp[cnt][sum]
- double rec(int cnt, int sum) {
- if( sum < 0 ) return 0;
- if( dp[cnt][sum] != -1 )
- return dp[cnt][sum];
- double result = 0;
- FORN(a,6)
- result += rec(cnt-1,sum-a)/6;
- return dp[cnt][sum] = result;
- }
- int main() {
- //freopen(TASK ".in", "r", stdin);
- //freopen(TASK ".out", "w", stdout);
- freopen("input.txt", "r", stdin);
- //freopen("output.txt", "w", stdout);
- //freopen("info.txt", "r", stdin);
- //freopen("info.txt", "w", stdout);
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int n,q; cout << setprecision(3) << fixed;
- while( cin >> n >> q ) {
- FOR(i,501) FOR(j,3001) dp[i][j] = -1;
- FOR(j,3001) dp[1][j] = dp[0][j] = 0;
- FORN(j,6)
- dp[1][j] = 1.0 / 6.0;
- cout << rec(n,q) << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement