数列极差。。。

xuke535010084 xuke535010084 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
http://acm.sdut.edu.cn/judgeonline/showproblem?problem_id=1894
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
#define MAX 99999999
bool cmp (const int a, const int b)
{
return a > b;
}
int main()
{
long n, i, a[50001], tempn, b[50001], min, max,num,t;

while (scanf("%d", &n)!=EOF)
{
for (i = 0; i < n; i++)
{
scanf("%d", &a[i]);
b[i] = a[i];
}

tempn = n;

while (tempn > 1)
{
sort(a, a+n);
a[1] = a[0]*a[1]+1;
a[0] = MAX;
tempn--;
}
max = a[1];

tempn = n;
while (tempn > 1)
{
sort(b, b+n, cmp);
b[1] = b[0]*b[1]+1;
b[0] = 0;
tempn--;
}
min = b[1];
num=max-min;
t=1;
while(num/10)
{
t++;
num/=10;
}
printf("%d\n",t);
printf("%0.lf\n", fabs(max-min));
}
return 0;
}这个是错的。。哪里不对。?
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
xuke535010084
C++ 语言 65,214 成员 250,514 内容