Logo
(追記) (追記ここまで)

18731번 - A Math Problem 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB80212027.027%

문제

Zenyk is given a sequence of n integers a1, . . . , an and a sequence of m integers b1, . . . , bm. Both sequences contain only positive integers. You built a matrix of size n × m such that an element at the i-th row and the j-th column has value of LCM (least common multiple) of values ai and bj.

Now he wants to know how many pairs of sequences c and d are there that produce the same matrix.

입력

The first line contains two integers n and m (1 ≤ n, m ≤ 105). The second line contains n integers a1, . . . , an. The third line contains m integers b1, . . . , bm (1 ≤ ai, bj ≤ 109).

출력

The number of pairs modulo 1 000 000 007 (109 + 7).

제한

예제 입력 1

2 3
2 10
28 3 4

예제 출력 1

5

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2020 > Day 6: Lviv NU Contest B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /