Balls and Boxes 题目链接:点我打开链接 Author SYSU Source 2016 Multi-University Training Contest 7 题意:给你n个球往m个盒子里扔,每个球扔进每个盒子的几率一样。问你:方差V 的
Balls and Boxes
题目链接:点我打开链接
Author
SYSU
Source
2016 Multi-University Training Contest 7
题意:给你n个球往m个盒子里扔,每个球扔进每个盒子的几率一样。问你:方差V
的期望
是多少。
我自己是猛怼规律,猛找公式的。。。
官方题解:
AC代码:
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int read()
{
int v = 0, f = 1;
char c =getchar();
while( c < 48 || 57 < c ){
if(c=='-') f = -1;
c = getchar();
}
while(48 <= c && c <= 57)
v = v*10+c-48, c = getchar();
return v*f;
}
int main()
{
ll n,m;
ll A,B;
while(~scanf("%I64d%I64d",&n,&m),n,m)
{
A=n*(m-1);
B=m*m;
ll ans=__gcd(A,B);
printf("%I64d/%I64d\n",A/ans,B/ans);
}
return 0;
}