编程介的小学生 2020-01-17 21:52 采纳率: 20.5%
浏览 156

Big Division 分割的问题

Problem Description
A theoretical physicist friend is doing research about the "Answer to the Ultimate Question of Life, the Universe, and Everything", he thinks that it is not 42 as suggested by “The Hitchhiker's Guide to the Galaxy” science fiction comedy series; instead he thinks it is the result of dividing the products of two sequences of positive integers A and B!
The task of calculating the product of A and B followed by division turned out to be not as easy as it looks, specially with the sequences being long and the products getting too large very quickly! Even using a modern computer, a straight forward implementation for the calculations may take very long time to complete! And this is where we seek your help as a brilliant computer scientist!

Input
The first line of input contains an integer (1 <= T <= 200), the number of test cases.
T test cases follow, the first line of each test case contains two integers (1 <= N, M<= 110,000), the lengths of sequences A and B respectively. Two lines follow, the first line contains N space separated integers (0 < A0, A1 … An <= 1,000,000), and the second line contains M space separated integers (0 < B0, B1 … Bm <= 1,000,000).

Output
For each test case, print one line containing the result of dividing the product of sequence A by the product of sequence B as a reduced fraction of the format “X / Y” (Notice the single space before and after the fraction sign). X and Y are guaranteed to fit in 32-bit signed integer. A reduced fraction is a fraction such that the greatest common divisor between the nominator and the denominator is 1.

Sample Input
2
3 1
2 4 5
12
2 4
1 15
5 1 7 2

Sample Output
Case #1: 10 / 3
Case #2: 3 / 14

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算