isothermal's blog

By isothermal, history, 4 years ago, In English

include

include <bits/stdc++.h>

using namespace std;

int main(){

//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);

long long int n,a[100009],i,j,cost,r,mini;
cin>>n;
for(i=0;i<n;i++)
    cin>>a[i];
sort(a,a+n);


mini=1000000000000000;
j=1;
r=0;
while(1)
{

    cost=0;
for(i=0;i<n;i++)
{

    cost=cost+(long long int)(abs((double)a[i]-pow((double)j,(double)i)));
    if(pow((double)j,(double)i)>10000000000)
    {
        r=1;
        break;
    }

}

    if(r==1)
    {
        break;
    }
  if(cost<mini)
  mini=cost;
  j++;
}
cout<<mini;
return 0;

} I have copied the code.i think there is a bug in cf,i may be wrong.Please guide me.Thanks in advance. INPUT: 20 51261 11877 300 30936722 84 75814681 352366 23 424 16392314 27267 832 4 562873474 33 516967731 158909407 32148531 66 757 OUTPUT for local machine and other online judge: 850575966 OUTPUT for cf judge: 850575960 This is 3rd test case of problem B of DIV 2 round 666. please help. Thanks.

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it