BD. [TJOI2009] 猜数字

    Type: RemoteJudge 1000ms 125MiB

[TJOI2009] 猜数字

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

现有两组数字,每组 kk 个。

第一组中的数字分别用 a1,a2,,aka_1,a_2,\cdots ,a_k 表示,第二组中的数字分别用 b1,b2,,bkb_1,b_2,\cdots ,b_k 表示。

其中第二组中的数字是两两互素的。求最小的 nNn\in \mathbb{N},满足对于 i[1,k]\forall i\in [1,k],有 bi(nai)b_i | (n-a_i)

输入格式

第一行一个整数 kk

第二行 kk 个整数,表示:a1,a2,,aka_1,a_2,\cdots ,a_k

第三行 kk 个整数,表示:b1,b2,,bkb_1,b_2,\cdots ,b_k

输出格式

输出一行一个整数,为所求的答案 nn

3
1 2 3
2 3 5

23

提示

对于 100%100\% 的数据:

1k101\le k \le 10ai109|a_i|\le 10^91bi6×1031\le b_i\le 6\times 10^3i=1kbi1018\prod_{i=1}^k b_i\le 10^{18}

每个测试点时限 11 秒。

注意:对于 C/C++ 语言,对 6464 位整型数应声明为 long long

若使用 scanfprintf 函数(以及 fscanffprintf 等),应采用 %lld 标识符。

【A班】数学问题S

Not Claimed
Status
Done
Problem
62
Open Since
2025-10-22 0:00
Deadline
2025-11-28 23:59
Extension
24 hour(s)