#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