比赛 202110省实验桐柏一中普及组联赛 评测结果 AAAAAAAAAW
题目名称 分数运算 最终得分 90
用户昵称 PIG 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2021-10-18 18:54:08
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
int fenshu, zhengshu, tmp;
long long fenzi[105] = {0}, fenmu[105] = {1}, lltmp;

long long gcd (long long a, long long b)
{
	return b == 0 ? a : gcd (b, a % b);
}

int main ()
{
	freopen ("fenshu.in", "r", stdin);
	freopen ("fenshu.out", "w", stdout);
	scanf ("%d %d", &fenshu, &zhengshu);

	for (int i = 1; i <= fenshu; ++i)
	{
		scanf ("%lld %lld", &fenzi[i], &fenmu[i]);
		fenzi[i] = fenzi[i - 1] * fenmu[i] + fenmu[i - 1] * fenzi[i];
		fenmu[i] *= fenmu[i - 1];
		lltmp = gcd (fenzi[i], fenmu[i]);
		fenzi[i] /= lltmp;
		fenmu[i] /= lltmp;
	}

	for (int i = 0; i ^ zhengshu; ++i)
	{
		scanf ("%d", &tmp);
		fenmu[fenshu] *= tmp;
		lltmp = gcd (fenzi[fenshu], fenmu[fenshu]);
		fenzi[fenshu] /= lltmp;
		fenmu[fenshu] /= lltmp;
	}
	
	printf ("%lld ", fenzi[fenshu]);
	
	if (fenmu[fenshu] != 1)
	{
		printf ("%lld ", fenmu[fenshu]);
	}
	
	return 0;
}