AT_abc479_g.Tuning
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given length-N integer sequences A=(A1,A2,…,AN) and B=(B1,B2,…,BN).
Consider length-N sequences of rational numbers c=(c1,c2,…,cN) and d=(d1,d2,…,dN) that satisfy the following condition.
- (Ai+ci)(Bj+dj)=(Aj+cj)(Bi+di) for all 1≤i,j≤N.
Find the minimum possible value of i=1∑N(∣ci∣+∣di∣).
It can be proved that the answer to this problem can be uniquely represented as an irreducible fraction p/q with a positive denominator and a non-negative numerator.
Output these p and q.
给你两个长度为 N 的整数序列 A=(A1,A2,…,AN) 和 B=(B1,B2,…,BN)。
考虑满足以下条件的长度为 N 的有理数序列 c=(c1,c2,…,cN) 和 d=(d1,d2,…,dN):
- 对所有 1≤i,j≤N,均有 (Ai+ci)(Bj+dj)=(Aj+cj)(Bi+di)。
求 i=1∑N(∣ci∣+∣di∣) 的最小可能值。
可以证明,本题的答案可唯一表示为最简分数 p/q,其中分母 q 为正整数,分子 p 为非负整数。
请输出该 p 和 q。
输入格式
The input is given from Standard Input in the following format:
N
A1 A2 … AN
B1 B2 … BN
输入从标准输入中按以下格式给出:
N
A1 A2 … AN
B1 B2 … BN
输出格式
When the answer to this problem is represented as an irreducible fraction p/q with a positive denominator and a non-negative numerator, output it in the following format:
p q
当本题的答案表示为最简分数 p/q(分母为正数,分子为非负数)时,请按以下格式输出:
p q
输入输出样例
输入#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,−41,0), which achieves ∑i=1N(∣ci∣+∣di∣)=41.
Also, ∑i=1N(∣ci∣+∣di∣) cannot be made smaller than this.
Sample 2 Explanation:
If the answer is 0, it is represented as 0/1, so output 0 1.
Constraints
- All input values are integers.
- 2≤N≤2×105
- ∣Ai∣,∣Bi∣≤106
样例 1 解释:
例如,可取 c=(0,0,0), d=(0,−41,0),此时 ∑i=1N(∣ci∣+∣di∣)=41。
此外,∑i=1N(∣ci∣+∣di∣) 无法再小于此值。
样例 2 解释:
若答案为 0,则表示为 0/1,因此输出 0 1。
约束条件
- 所有输入值均为整数。
- 2≤N≤2×105
- ∣Ai∣, ∣Bi∣≤106
输入解题思路,AI测评打分。不知道怎么写?