CF1687D.Cute number
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Ran is especially skilled in computation and mathematics. It is said that she can do unimaginable calculation work in an instant.
—Perfect Memento in Strict Sense
Ran Yakumo is a cute girl who loves creating cute Maths problems.
Let f(x) be the minimal square number strictly greater than x, and g(x) be the maximal square number less than or equal to x. For example, f(1)=f(2)=g(4)=g(8)=4.
A positive integer x is cute if x−g(x)<f(x)−x. For example, 1,5,11 are cute integers, while 3,8,15 are not.
Ran gives you an array a of length n. She wants you to find the smallest non-negative integer k such that ai+k is a cute number for any element of a.
莲尤其擅长计算与数学。据说她能在瞬间完成难以想象的计算工作。
——《严格意义下的完美记忆》
八云莲是一位喜爱创造可爱数学题的可爱女孩。
令 f(x) 表示严格大于 x 的最小平方数,而 g(x) 表示小于或等于 x 的最大平方数。例如,f(1)=f(2)=g(4)=g(8)=4。
一个正整数 x 被称为“可爱的”,当且仅当 x−g(x)<f(x)−x。例如,1,5,11 是可爱的整数,而 3,8,15 则不是。
莲给你一个长度为 n 的数组 a。她希望你找出最小的非负整数 k,使得对数组 a 中的每个元素 ai,ai+k 都是可爱的数。
输入格式
The first line contains one integer n (1≤n≤106) — the length of a.
The second line contains n intergers a1,a2,…,an (1≤a1≤a2≤…≤an≤2⋅106) — the array a.
第一行包含一个整数 n(1≤n≤106)—— 表示数组 a 的长度。
第二行包含 n 个整数 a1,a2,…,an(1≤a1≤a2≤…≤an≤2⋅106)—— 表示数组 a。
输出格式
Print a single interger k — the answer.
输出一个整数 k —— 答案。
输入输出样例
输入#1
4 1 3 8 10
输出#1
1
输入#2
5 2 3 8 9 11
输出#2
8
输入#3
8 1 2 3 4 5 6 7 8
输出#3
48
说明/提示
Test case 1:
3 is not cute integer, so k=0.
2,4,9,11 are cute integers, so k=1.
测试用例 1:
3 不是可爱的整数,因此 k=0。
2,4,9,11 是可爱的整数,因此 k=1。
输入解题思路,AI测评打分。不知道怎么写?