/*********
Author Smile
竞赛中有很多题目就是吓唬人的
虽然看着很复杂,但是仔细一想
也就那么回事,而且里面有很多东西
就是为了吓唬你而做准备的
要勤于计算,在计算中要找规律
大胆猜想
https://vjudge.csgrandeur.cn/contest/477345#problem/K
*********/
#include <iostream>
#include <cmath>
using namespace std;
typedef long long LL;
const LL N = 1e6 + 10;
LL n;
LL a[N];
LL ans = 0;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> n;
for (int i = 1; i <= n; ++i)
{
cin >> a[i];
}
if (n == 1)
cout << a[1] << ".0000000000" << endl;
else if (n == 2)
cout << abs(a[2] - a[1]) << ".0000000000" << endl;
else
{
LL temp = abs(a[n] - a[n - 1]);
for (int i = n - 2; i >= 1; --i)
{
ans = abs(a[i] - temp);
temp = ans;
}
cout << ans << ".0000000000" << endl;
}
return 0;
}
在计算中找规律(大胆猜想 + 逆向思维)
最新推荐文章于 2024-07-19 23:11:36 发布