单点时限: 1.0 sec
内存限制: 256 MB
//********** Specification of FractionSum **********
long long FractionSum(int aaaabbbb, int ccccdddd);
/* PreCondition:
aaaabbbb和ccccdddd表示分数aaaa/bbbb和cccc/dddd,分子分母最多4位数
PostCondition:
计算两个分数之和,返回其最简分数xxxxxxxxyyyyyyyy
*/
//********** Specification of FractionSum **********
long long FractionSum(int aaaabbbb, int ccccdddd) { //TODO: your function definition
}
#include <stdio.h>
int main() {
int a, b, c, d;
long long r;
scanf("%d%d%d%d", &a, &b, &c, &d);
r = FractionSum(a * 10000 + b, c * 10000 + d);
printf("%d/%d+%d/%d=%lld/%lld.\n", a, b, c, d,
r / 100000000, r % 100000000);
return 0;
}
输入四个整数 $a,b,c,d$ ($1 \le a,b,c,d < 10000$)。
1 2 3 4
1/2+3/4=5/4.