Welcome, Guest! Sign Up RSS

Clever Space

Friday, 11.22.2024
Main » 2013 » October » 22

简单的概率题,注意用分数运算

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<iostream>
#include<string>
#include<cmath>
#define N 1010
#define FOR(i,a,b) for(i=(a);i<=(b);i++)
#define ROF(i,a,b) for(i=(a);i>=(b);i--)
typedef long long LL;
using namespace std;
struct num{LL c,p;};
int g[N][N],value[N],n,m;
LL gcd(LL a,LL b){if (a%b==0) return b;return gcd(b,a%b);}
LL lcm(LL a,LL b){return a*b/gcd(a,b);}
num operator+(num A,num B)
{
  num C;
  LL G=lcm(A.p,B.p);
  A.c*=G/A.p;B.c*=G/B.p;
  C.c=A.c+B.c;C.p=G;
  return C;
}
Views: 482 | Added by: dhy0077 | Date: 10.22.2013

又NC了,这就是一最短路

把每个节点分开的话,它们是没有依赖关系的。

Views: 338 | Added by: dhy0077 | Date: 10.22.2013