# POJ 3682 King Arthur's Birthday Celebration 概率DP

#### 解出花费为n2+np2−np 解出花费为\frac{n^2+n}{p^2}-\frac{n}{p}

http://poj.org/problem?id=3682

/*********************************************
Problem : POJ 3682
Author  : NMfloat
********************************************/

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>

#define rep(i,a,b)  for(int i = (a) ; i <= (b) ; i ++) //遍历
#define rrep(i,a,b) for(int i = (b) ; i >= (a) ; i --) //反向遍历
#define repS(it,p) for(auto it = p.begin() ; it != p.end() ; it ++) //遍历一个STL容器
#define repE(p,u) for(Edge * p = G[u].first ; p ; p = p -> next) //遍历u所连接的点
#define cls(a,x)   memset(a,x,sizeof(a))
#define eps 1e-8

using namespace std;

const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e5+5;
const int MAXE = 2e5+5;

typedef long long LL;
typedef unsigned long long ULL;

int T,n,m;

int fx[] = {0,1,-1,0,0};
int fy[] = {0,0,0,-1,1};

double p;

void input() {
scanf("%lf",&p);
}

void solve() {
printf("%.3f %.3f\n",n/p,((n*n+n)/p-n)/p);
}

int main(void) {
//freopen("a.in","r",stdin);
while(scanf("%d",&n),n) {
input();
solve();
}
return 0;
}
07-02 1191

10-31 296
08-26 37
05-12 87
04-03 176
11-09 30万+
06-23 14
03-28 3041
12-23 1万+