アットウィキロゴ

12 12 12

class tax11{
public static void main(String args[]){
int n,s1,s2,n1,n2;
double th1[]=new double[11];
double th2[]=new double[11];
double y1[][]=new double[11][11];
double y2[][]=new double[11][11];
double c[][]=new double[11][11];
double up[][]=new double[11][11];
int mrank[]=new int[101];
int frank[]=new int[101];
double tk,tl,tr,tks,tls;
double b1,w1,maxw,l1,l2,minu;
for (s1=1;s1<11;s1++){
th1[s1]=0.2*s1;
}
for (s2=1;s2<11;s2++){
th2[s2]=0.1*s2;
}
maxw=-999;
tls=0;
tks=0;
for (n1=5;n1<41;n1++){
for (n2=5;n2<41;n2++){
tk=0.01*n1;
tl=0.01*n2;
tr=trs(tk,tl,th1,th2);
w1=wel(tk,tl,tr,th1,th2);
if (w1>maxw)tks=tk;
if (w1>maxw)tls=tl;
if (w1>maxw)maxw=w1;
}
}
tk=tks;
tl=tls;
tr=trs(tk,tl,th1,th2);
for (s1=1;s1<11;s1++){
for (s2=1;s2<11;s2++){
y1[s1][s2]=th1[s1]*mlx(s1,s2,tk,tl,tr,th1,th2);
y2[s1][s2]=th2[s2]*flx(s1,s2,tk,tl,tr,th1,th2);
c[s1][s2]=(1-tk)*y1[s1][s2]+(1-tl)*y2[s1][s2]+tr;
l1=y1[s1][s2]/th1[s1];
l2=y2[s2][s2]/th2[s2];
up[s1][s2]=u(c[s1][s2],1-l1,1-l2);
}
}
for (n=1;n<101;n++){
minu=999;
for (s1=1;s1<11;s1++){
for (s2=1;s2<11;s2++){
if (up[s1][s2]<minu)mrank[n]=s1;
if (up[s1][s2]<minu)frank[n]=s2;
if (up[s1][s2]<minu)minu=up[s1][s2];
}
}
s1=mrank[n];
s2=frank[n];
up[s1][s2]=9999;
System.out.println(n);
System.out.println(s1);
System.out.println(s2);
}
}
public static double mlx(int s1,int s2,double tk,double tl,double tr,double th1[],double th2[]){
double c1,w1,w2,l1,l2;
int h;
w1=(1-tk)*th1[s1];
w2=(1-tl)*th2[s2];
c1=(w1+w2+tr)/3;
l1=1-c1/w1;
l2=1-c1/w2;
h=0;
if (l1<0)h=h+1;
if (l2<0)h=h+2;
if (h==1)l2=(w2-tr)/(2*w2);
if (h==1)l1=0;
if (h==2)l1=(w1-tr)/(2*w1);
if (h==2)l2=0;
if (h==3)l1=0;
if (h==3)l2=0;
return l1;
}
public static double cx(int s1,int s2,double tk,double tl,double tr,double th1[],double th2[]){
double c1,w1,w2,l1,l2;
w1=(1-tk)*th1[s1];
w2=(1-tl)*th2[s2];
l1=mlx(s1,s2,tk,tl,tr,th1,th2);
l2=flx(s1,s2,tk,tl,tr,th1,th2);
c1=w1*l1+w2*l2+tr;
return c1;
}
public static double flx(int s1,int s2,double tk,double tl,double tr,double th1[],double th2[]){
double c1,w1,w2,l1,l2;
int h;
w1=(1-tk)*th1[s1];
w2=(1-tl)*th2[s2];
c1=(w1+w2+tr)/3;
l1=1-c1/w1;
l2=1-c1/w2;
h=0;
if (l1<0)h=h+1;
if (l2<0)h=h+2;
if (h==1)l2=(w2-tr)/(2*w2);
if (h==1)l1=0;
if (h==2)l1=(w1-tr)/(2*w1);
if (h==2)l2=0;
if (h==3)l1=0;
if (h==3)l2=0;
return l2;
}
public static double wel(double tk,double tl,double tr,double th1[],double th2[]){
double c1,l1,l2,w1;
int s1,s2;
w1=0;
for (s1=1;s1<11;s1++){
for (s2=1;s2<11;s2++){
l1=mlx(s1,s2,tk,tl,tr,th1,th2);
l2=flx(s1,s2,tk,tl,tr,th1,th2);
c1=cx(s1,s2,tk,tl,tr,th1,th2);
w1=w1+u(c1,1-l1,1-l2);
}
}
return w1;
}
public static double bud(double tk,double tl,double tr,double th1[],double th2[]){
double c1,y1,y2,b1;
int s1,s2;
b1=0;
for (s1=1;s1<11;s1++){
for (s2=1;s2<11;s2++){
y1=th1[s1]*mlx(s1,s2,tk,tl,tr,th1,th2);
y2=th2[s2]*flx(s1,s2,tk,tl,tr,th1,th2);
c1=cx(s1,s2,tk,tl,tr,th1,th2);
b1=b1+y1+y2-c1;
}
}
return b1;
}
public static double trs(double tk,double tl,double th1[],double th2[]){
double tr1,tr2,tr3,b1,b2;
int t;
tr1=0.1;
tr2=0.2;
b1=bud(tk,tl,tr1,th1,th2);
t=0;
while (t<100){
b2=bud(tk,tk,tr2,th1,th2);
tr3=tr2-b2*(tr2-tr1)/(b2-b1);
b1=b2;
tr1=tr2;
tr2=tr3;
if (b2*b2<0.0001)t=1000;
t=t+1;
}
return tr2;
}
public static double u(double c1,double x1,double x2){
double u1,c2,x3,x4;
int h;
c2=c1;
x3=x1;
x4=x2;
h=0;
if (c2<0)h=100;
if (c2==0)h=100;
if (x3<0)h=100;
if (x3==0)h=100;
if (x4<0)h=100;
if (x4==0)h=100;
if (h>50)c2=0.5;
if (h>50)x3=0.5;
if (h>50)x4=0.5;
u1=Math.log(c2)+Math.log(x3)+Math.log(x4);
if (h>50)u1=-999;
return u1;
}

}
最終更新:2010年05月09日 14:22