本蒟蒻的第一篇题解,如有错误请大家悉心指出。
咕了 个多月后在月赛 的第 道题…这是 篇为爆码风而生的题解
【分析】
其实这道题只要让最大的那个数最大就行了。所以我们先排一下序:sort(a+1,a+1+n);再对最大的那个数 进行操作即可。
经过枚举,我们发现:
-
当 时, 更大。
-
当 时, 和 一样大。
-
当 时, 更大。
其中, 可以并到上下 种情况中。(因为我是从小到大讨论的,所以我把它并到了下面那种情况里)
让我们康一下数据范围,好家伙, , ,假如 , 那么让它乘 次 (也就是 ,即 )它就会变成 , 位,爆 了,所以:
十年 一场空,不开 见祖宗。
【 代码】
#define itn int
#include<algorithm>
#include<stdio.h>
using namespace std;
#define int long long
const int N=1e6+10;
inline int fread()
{
char ch=getchar();
int n=0,m=1;
while(ch<'0' or ch>'9')
{
if(ch=='-')m=-1;
ch=getchar();
}
while(ch>='0' and ch<='9')n=(n<<3)+(n<<1)+ch-48,ch=getchar();
return n*m;
}
void fwrite(int n)
{
if(n>9)fwrite(n/10);
putchar(n%10+'0');
}
itn n=fread(),m=fread(),a[N];
signed main()
{
for(int i=1;i<=n;i++)a[i]=fread();
sort(a+1,a+1+n);
while(m--)
{
if(a[n]<2)a[n]+=2;
else a[n]*=2;
}
fwrite(a[n]-a[1]);
return 0;
}高尔基曾经说过:
莫抄袭,棕了你的名,空悲切!