|
|
вернуться в форумIs this prog not correct? var a:array[1..100] of longint; n,i,j:longint; max:extended; begin readln(n); max:=0; for i:=1 to n do begin readln(a[i]); for j:=1 to i-1 do if sqrt(a[j]*a[i])>max then max:=sqrt(a[j]*a[i]) end; writeln((max*2):0:2); end. Re: Is this prog not correct? No. Your program finds the maximal value of a[i]*a[j]. Your task is different. Let you have n numbers: a[1],...,a[n]. You can change any two numbers a[i], a[j] with 2*sqrt(a[i],a[j]). So you've got another sequence : b [1],...,b[n-1], where b[1]=a[1]; ... b[i-1]=a[i-1]; b[i]=2*sqrt(a[i],a[j]); b[i+1]=a[i+1]; ... b[j-1]=a[j-1]; b[j]=a[j+1]; ... b[n-1]=a[n]. Repeat procedure until you'll get the only integer. You are to find the minimal value of this number. Good luck! Re: Is this prog not correct? Its solution is not correct!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|
|