链接:
来源:牛客网 skywalkert, the new legend of Beihang University ACM-ICPC Team, retired this year leaving a group of newbies again.
.
means the Lowest Common Multiple.
Rumor has it that he left a heritage when he left, and only the one who has at least 0.1% IQ(Intelligence Quotient) of his can obtain it.
To prove you have at least 0.1% IQ of skywalkert, you have to solve the following problem: Given n positive integers, for all (i, j) where 1 ≤ i, j ≤ n and i ≠ j, output the maximum value among 输入描述:
The input starts with one line containing exactly one integer t which is the number of test cases. (1 ≤ t ≤ 50) For each test case, the first line contains four integers n, A, B, C. (2 ≤ n ≤ 10
7
, A, B, C are randomly selected in unsigned 32 bits integer range)
The n integers are obtained by calling the following function n times, the i-th result of which is a i, and we ensure all a i > 0. Please notice that for each test case x, y and z should be reset before being called.
No more than 5 cases have n greater than 2 x 10
6
.
输出描述:
For each test case, output "Case #x: y" in one line (without quotes), where x is the test case number (starting from 1) and y is the maximum lcm.
示例1
输入
22 1 2 35 3 4 8
输出
Case #1: 68516050958Case #2: 5751374352923604426 分析:由于数据看上去像是随机⽣成的,只需要选出前 100 ⼤的数平⽅暴⼒即可。 随机两个正整数互质的概率为 6/π。 比赛的时候想到应该是枚举前面最大的多少项,但是因为不知道怎么快速计算前面多少项没有试一发了!! 结束后补题知道了nth_element求数组中最大的前多少项 AC代码:
#include