编程介的小学生 2017-01-12 14:28 采纳率: 20.5%
浏览 845
已采纳

GCD Determinant

Description

We say that a set S = {x1, x2, ..., xn} is factor closed if for any xi ∈ S and any divisor d of xi we have d ∈ S. Let’s build a GCD matrix (S) = (sij), where sij = GCD(xi, xj) – the greatest common divisor of xi and xj. Given the factor closed set S, find the value of the determinant:

D_n = \left|{\begin{array}{ccccc}gcd(x_1,x_1)&gcd(x_1,x_2)&gcd(x_1,x_3)&\cdots&gcd(x_1,x_n)\gcd(x_2,x_1)&gcd(x_2,x_2)&gcd(x_2,x_3)&\cdots&gcd(x_2,x_n)\gcd(x_3,x_1)&gcd(x_3,x_2)&gcd(x_3,x_3)&\cdots&gcd(x_3,x_n)\\cdots&\cdots&\cdots&\cdots&\cdots\gcd(x_n,x_1)&gcd(x_n,x_2)&gcd(x_n,x_3)&\cdots&gcd(x_n,x_n)\end{array}}\right|
Input

The input file contains several test cases. Each test case starts with an integer n (0 < n < 1000), that stands for the cardinality of S. The next line contains the numbers of S: x1, x2, ..., xn. It is known that each xi is an integer, 0 < xi < 2*109. The input data set is correct and ends with an end of file.
Output

For each test case find and print the value Dn mod 1000000007.
Sample Input

2
1 2
3
1 3 9
4
1 2 3 6
Sample Output

1
12
4

  • 写回答

2条回答

  • threenewbee 2017-01-18 15:56
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 软件自定义无线电该怎样使用
  • ¥15 Jenkins+k8s部署slave节点offline
  • ¥15 微信小游戏反编译后,出现找不到分包的情况
  • ¥15 如何实现从tello无人机上获取实时传输的视频流,然后将获取的视频通过yolov5进行检测
  • ¥15 WPF使用Canvas绘制矢量图问题
  • ¥15 用三极管设计一个单管共射放大电路
  • ¥15 孟德尔随机化r语言运行问题
  • ¥15 pyinstaller编译的时候出现No module named 'imp'
  • ¥15 nirs_kit中打码怎么看(打码文件是csv格式)
  • ¥15 怎么把多于硬盘空间放到根目录下