package non2;
public class linear{
int s;
double th=new double[101];
int p=new int[101];
int[] x=new int[101];
int p0,p1,px,py;
double z1,z2,r1;
double rev;
int x1,s1,s2;
int cost;
void makedata(){
p0=20;
p1=20;
double maxv;
maxv=0;
for(s1=5;s1<20;s1++){
for(s2=1300;s2<1800;s2++){
p1=s1;
p0=s2;
r1=rev(p0,p1);
if(r1>maxv)px=p0;
if(r1>maxv)py=p1;
if(r1>maxv)maxv=r1;
}
}
p1=py;
p0=px;
for(s=1;s<101;s++){
x[s]=demand(s,p0,p1);
if(x[s]>0)p[s]=p0+p1*x[s];
}
System.out.println(p0);
System.out.println(p1);
}
double rev(int p0,int p1){
double x1,z1,z2;
int s;
z2=0;
for(s=1;s<101;s++){
x1=demand(s,p0,p1);
z1=0;
z1=p0+p1*x1-cost*x1;
if(x1>0)z2=z2+z1;
}
return z2;
}
int demand(int s,double p0,double p1){
double x1,u1,u2,u0;
int y1,y2;
x1=th[s]/p1-1;
y1=(int)x1;
y2=y1+1;
if(y1<0)y1=0;
if(y2<0)y2=0;
u1=th[s]*Math.log(y1+1)-p0-p1*y1;
u2=th[s]*Math.log(y2+1)-p0-p1*y2;
if(u2>u1)y1=y2;
if(u2>u1)u1=u2;
u0=Math.log(1);
if(u0>u1)y1=0;
return y1;
}
}