#include<iostream>
#include<cmath>
int a[1000010];
using namespace std;
int main()
{
int n,len,num,i,j,t,temp1,temp2;
cin>>n;
for(i=0;i<n;i++)
{
cin>>len>>num;
for(j=0;j<num;j++)
{
cin>>a[j];
}
temp1=0;
for(j=0;j<num;j++)
{
if(a[j]>=(len-a[j]))
t=a[j];
else
t=len-a[j];
if(t>temp1)
temp1=t;
}
temp2=abs(a[0]*10-(len*5));
for(j=0;j<num;j++)
{
t=abs(a[j]*10-(len*5));
if(t<temp2)
temp2=t;
}
temp2=(len*5)-temp2;
temp2=temp2/10;
cout<<temp2<<" "<<temp1<<endl;
}
}
poj 1852 蚂蚁问题,很经典,实际上就是找最靠近边缘和最靠近中间,靠近边缘要注意小数的处理
最新推荐文章于 2022-03-19 00:17:45 发布
本文介绍了一个使用C++编写的程序,该程序读取一系列整数并计算这些整数相对于中心位置的最大偏离距离及最接近中心位置的距离。通过对输入数据的处理,程序展示了如何使用条件判断和循环来解决问题。

931

被折叠的 条评论
为什么被折叠?



