アットウィキロゴ

071602

class pro{
public static void main(String args[]){
int s1,s2;
int n1,n2,n3;
int j;
double p1,p2,c;
double u1,u2,u3;
double x1,x2;
double r1,r2;
double alpha,beta,cost1,cost2;
double maxp1,maxp2,maxc,maxr;
double th1[]=new double[6];
double th2[]=new double[6];
for (s1=1;s1<6;s1++){
th1[s1]=s1;
}
for (s2=1;s2<6;s2++){
th2[s2]=s2;
}

alpha=1;
beta=1;
cost1=1;
cost2=1;

maxp1=0;
maxp2=0;
maxc=0;
maxr=0;
for (n1=1;n1<51;n1++){
for (n2=1;n2<51;n2++){
for (n3=1;n3<51;n3++){
p1=0.1*n1;
p2=0.1*n2;
c=0.1*n3;
r2=0;
for (s1=1;s1<6;s1++){
for (s2=1;s2<6;s2++){
x1=(th1[s1]-p1)/(2*alpha);
if (x1<0)x1=0;
x2=(th2[s2]-p2)/(2*beta);
if (x2<0)x2=0;  
u1=th1[s1]*x1-alpha*x1*x1-p1*x1;
u2=th2[s2]*x2-beta*x2*x2-p2*x2;  
u3=u1+u2-c;
if (u3<0)x1=0;
if (u3<0)x2=0;
r1=p1*x1+p2*x2+c-cost1*x1-cost2*x2;
j=0;
if (x1==0)j=j+1;
if (x2==0)j=j+1;
if (j==2)r1=0;
r2=r2+r1;
}
}
if (r2>maxr)maxp1=p1;
if (r2>maxr)maxp2=p2;
if (r2>maxr)maxc=c;
if (r2>maxr)maxr=r2;
}
}
}
System.out.println(maxp1);
System.out.println(maxp2);
System.out.println(maxc);
System.out.println(maxr);



}
}
最終更新:2010年07月16日 05:17