アットウィキロゴ

pro pro 1

#include <stdio.h>
#include <math.h>
int main(void){
double th1[11],th2[11];
int s1,s2,j,t,m1,m2;
double tk,tl,tr,tr1,tr2,tr3,w1,w2,c1,l1,l2,b1,b2,wel;
double maxw,maxk,maxl;
for (s1=1;s1<=10;s1++){
th1[s1]=0.2*s1;
}
for (s2=1;s2<=10;s2++){
th2[s2]=0.1*s2;
}
maxw=-999;
for (m1=10;m1<=40;m1++){
for (m2=10;m2<=40;m2++){
tk=0.01*m1;
tl=0.01*m2;
tr1=0.05;
tr2=0.1;
b1=0;
for (s1=1;s1<=10;s1++){
for (s2=1;s2<=10;s2++){
w1=(1-tk)*th1[s1];
w2=(1-tl)*th2[s2];
c1=(w1+w2+tr1)/3;
l1=1-c1/w1;
l2=1-c1/w2;
j=0;
if (l1<0) j=j+1;
if (l2<0) j=j+1;
if (j==2) l1=0;
if (j==2) l2=0;
if (j==2) c1=tr1;
j=0;
if (l1<0) j=j+1;
if (l2>0) j=j+1;
if (j==2) l1=0;
if (j==2) l2=(w2-tr1)/(2*w2);
if (j==2) c1=w2*l2+tr1;
j=0;
if (l1>0) j=j+1;
if (l2<0) j=j+1;
if (j==2) l2=0;
if (j==2) l1=(w1-tr1)/(2*w1);
if (j==2) c1=w1*l1+tr1;
b1=b1+th1[s1]*l1+th2[s2]*l2-c1;
}
}
t=0;
while (t<100){
b2=0;
for (s1=1;s1<=10;s1++){
for (s2=1;s2<=10;s2++){
w1=(1-tk)*th1[s1];
w2=(1-tl)*th2[s2];
c1=(w1+w2+tr2)/3;
l1=1-c1/w1;
l2=1-c1/w2;
j=0;
if (l1<0) j=j+1;
if (l2<0) j=j+1;
if (j==2) l1=0;
if (j==2) l2=0;
if (j==2) c1=tr2;
j=0;
if (l1<0) j=j+1;
if (l2>0) j=j+1;
if (j==2) l1=0;
if (j==2) l2=(w2-tr2)/(2*w2);
if (j==2) c1=w2*l2+tr2;
j=0;
if (l1>0) j=j+1;
if (l2<0) j=j+1;
if (j==2) l2=0;
if (j==2) l1=(w1-tr2)/(2*w1);
if (j==2) c1=w1*l1+tr2;
b2=b2+th1[s1]*l1+th2[s2]*l2-c1;
}
}
tr3=tr2-b2*(tr2-tr1)/(b2-b1);
b1=b2;
tr1=tr2;
tr2=tr3;
if (b2*b2<0.0001)t=1000;
t=t+1;
}
tr=tr2;
wel=0;
for (s1=1;s1<=10;s1++){
for (s2=1;s2<=10;s2++){
w1=(1-tk)*th1[s1];
w2=(1-tl)*th2[s2];
c1=(w1+w2+tr)/3;
l1=1-c1/w1;
l2=1-c1/w2;
j=0;
if (l1<0) j=j+1;
if (l2<0) j=j+1;
if (j==2) l1=0;
if (j==2) l2=0;
if (j==2) c1=tr;
j=0;
if (l1<0) j=j+1;
if (l2>0) j=j+1;
if (j==2) l1=0;
if (j==2) l2=(w2-tr)/(2*w2);
if (j==2) c1=w2*l2+tr;
j=0;
if (l1>0) j=j+1;
if (l2<0) j=j+1;
if (j==2) l2=0;
if (j==2) l1=(w1-tr)/(2*w1);
if (j==2) c1=w1*l1+tr;
wel=wel+log(c1)+log(1-l1)+log(1-l2);
}
}
if (wel>maxw) maxk=tk;
if (wel>maxw) maxl=tl;
if (wel>maxw) maxw=wel;
printf("%f",wel);
printf("\n");
}
}
printf("%f",maxk);
printf("\n");
printf("%f",maxl);
return 0;
}
最終更新:2009年11月29日 06:31