AT_abc479_g.Tuning

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given length-NN integer sequences A=(A1,A2,…,AN)A=(A_1,A_2,\dots,A_N) and B=(B1,B2,…,BN)B=(B_1,B_2,\dots,B_N).
Consider length-NN sequences of rational numbers c=(c1,c2,…,cN)c=(c_1,c_2,\dots,c_N) and d=(d1,d2,…,dN)d=(d_1,d_2,\dots,d_N) that satisfy the following condition.

  • (Ai+ci)(Bj+dj)=(Aj+cj)(Bi+di)(A_i+c_i)(B_j+d_j)=(A_j+c_j)(B_i+d_i) for all 1≤i,j≤N1 \le i,j \le N.

Find the minimum possible value of ∑i=1N(∣ci∣+∣di∣)\displaystyle \sum_{i=1}^{N} \left ( |c_i|+|d_i| \right ).

It can be proved that the answer to this problem can be uniquely represented as an irreducible fraction p/qp/q with a positive denominator and a non-negative numerator.
Output these pp and qq.

给你两个长度为 NN 的整数序列 A=(A1,A2,…,AN)A=(A_1,A_2,\dots,A_N) 和 B=(B1,B2,…,BN)B=(B_1,B_2,\dots,B_N)。
考虑满足以下条件的长度为 NN 的有理数序列 c=(c1,c2,…,cN)c=(c_1,c_2,\dots,c_N) 和 d=(d1,d2,…,dN)d=(d_1,d_2,\dots,d_N):

  • 对所有 1≤i,j≤N1 \le i,j \le N,均有 (Ai+ci)(Bj+dj)=(Aj+cj)(Bi+di)(A_i+c_i)(B_j+d_j)=(A_j+c_j)(B_i+d_i)。

求 ∑i=1N(∣ci∣+∣di∣)\displaystyle \sum_{i=1}^{N} \left ( |c_i|+|d_i| \right ) 的最小可能值。

可以证明,本题的答案可唯一表示为最简分数 p/qp/q,其中分母 qq 为正整数,分子 pp 为非负整数。
请输出该 pp 和 qq。

输入格式

The input is given from Standard Input in the following format:

NN
A1A_1 A2A_2 …\dots ANA_N
B1B_1 B2B_2 …\dots BNB_N

输入从标准输入中按以下格式给出:

NN
A1A_1 A2A_2 …\dots ANA_N
B1B_1 B2B_2 …\dots BNB_N

输出格式

When the answer to this problem is represented as an irreducible fraction p/qp/q with a positive denominator and a non-negative numerator, output it in the following format:

pp qq

当本题的答案表示为最简分数 p/qp/q(分母为正数,分子为非负数)时,请按以下格式输出:

pp qq

输入输出样例

  • 输入#1

    3
    4 1 -8
    3 1 -6

    输出#1

    1 4
  • 输入#2

    2
    2 2
    3 3

    输出#2

    0 1
  • 输入#3

    10
    855263 -919070 120736 -779959 -789624 789495 -541451 139160 -406547 32421
    -612084 -707431 843213 834659 -424146 549941 -799392 -553082 732456 357127

    输出#3

    635454493436 120459

说明/提示

Sample 1 Explanation:
For example, you can set c=(0,0,0),d=(0,−14,0)c=(0,0,0),d=(0,-\frac{1}{4},0), which achieves ∑i=1N(∣ci∣+∣di∣)=14\sum_{i=1}^{N} \left ( |c_i|+|d_i| \right ) = \frac{1}{4}.
Also, ∑i=1N(∣ci∣+∣di∣)\sum_{i=1}^{N} \left ( |c_i|+|d_i| \right ) cannot be made smaller than this.

Sample 2 Explanation:
If the answer is 00, it is represented as 0/10/1, so output 0 1.

Constraints

  • All input values are integers.
  • 2≤N≤2×1052 \le N \le 2 \times 10^5
  • ∣Ai∣,∣Bi∣≤106|A_i|, |B_i| \le 10^6

样例 1 解释:
例如,可取 c=(0,0,0), d=(0,−14,0)c=(0,0,0),\ d=(0,-\frac{1}{4},0),此时 ∑i=1N(∣ci∣+∣di∣)=14\sum_{i=1}^{N} \left ( |c_i|+|d_i| \right ) = \frac{1}{4}。
此外,∑i=1N(∣ci∣+∣di∣)\sum_{i=1}^{N} \left ( |c_i|+|d_i| \right ) 无法再小于此值。

样例 2 解释:
若答案为 00,则表示为 0/10/1,因此输出 0 1。

约束条件

  • 所有输入值均为整数。
  • 2≤N≤2×1052 \le N \le 2 \times 10^5
  • ∣Ai∣, ∣Bi∣≤106|A_i|,\ |B_i| \le 10^6

输入解题思路,AI测评打分。不知道怎么写?

首页