当前位置:码农谷 > 算法与程序 > HDU 4987 Little Pony and Dice:题目解答源码

HDU 4987 Little Pony and Dice:题目解答源码

所属学科:C语言 - 结构体与共用体 难度: 关注度:15

Twilight Sparkle was playing Ludo with her friends Rainbow Dash, Apple Jack and Flutter Shy. But she kept losing. Having returned to the castle, Twilight Sparkle became interested in the dice that were used in the game.

The dice has m faces: the first face of the dice contains a dot, the second one contains two dots, and so on, the m-th face contains m dots. Twilight Sparkle is sure that when the dice is tossed, each face appears with same probability. Also she knows that each toss is independent from others.

There is n + 1 cells in total, number from 0 to n, Twilight Sparkle race her token from 0 to n according to die rolls. The game end once she move to n or over it. Help Twilight Sparkle calculated the probability she end the game exactly at n.

输入描述

Input contains multiple test cases (less than 200).
For each test case, only one line contains two integers m and n (1<=m, n<=10^9).

输出描述

For each case, output the corresponding result, rounded to 5 digits after the decimal point.


程序源码

完整的源代码如下

#include "iostream"#include "cstring"#include "string"#include "cstdio"#include "cmath"#include "algorithm"#include "vector"#include "queue"#include "map"#include"stack"using namespace std;typedef long long ll;const double eps=0.0000000000001;double dp[1000005];

关注微信,获得更多免费资源
关于我们   |   免责声明   |   联系我们   |   网站地图   |   HR交流群   |   学生交流群   |   教师交流群

码农谷   版权所有 © 2015-2017   湘ICP备16018319号-1