「cc01」の最新版変更点
追加された行はこの色になります。
削除された行はこの色になります。
- +#include <stdio.h> +#include <math.h> +int main(void) +{ +double th[101]; +double tl,d1,d2,c1,y1,l1,w1,tr; +double tr1,tr2,tr3; +double wel,maxwel,maxtl; +int s,t,n; +for (s=1;s<=100;s++){ +th[s] = 0.02*s; +} +maxwel=-999; +for (n=10;n<=40;n++){ +tl=0.01*n; +tr1=0.05; +tr2=0.03; +d1=0; +for (s=1;s<=100;s++){ +w1=(1-tl)*th[s]; +l1=(w1-tr1)/(2*w1); +if (l1<0) l1=0; +y1=th[s]*l1; +c1=w1*l1+tr1; +d1=d1+y1-c1; +} +t=0; +while(t<100){ +d2=0; +for (s=1;s<=100;s++){ +w1=(1-tl)*th[s]; +l1=(w1-tr2)/(2*w1); +if (l1<0) l1=0; +y1=th[s]*l1; +c1=w1*l1+tr2; +d2=d2+y1-c1; +} +tr3=tr2-d2*(tr2-tr1)/(d2-d1); +tr1=tr2; +tr2=tr3; +d1=d2; +if (d2*d2<0.01) t=1000; +t=t+1; +} +tr=tr2; +wel=0; +for (s=1;s<=100;s++){ +w1=(1-tl)*th[s]; +l1=(w1-tr)/(2*w1); +if (l1<0) l1=0; +c1=w1*l1+tr; +wel=wel+log(c1)+log(1-l1); +} +if (wel>maxwel) maxtl=tl; +if (wel>maxwel) maxwel=wel; +} +printf("%f",maxtl); +return 0; +}
このwikiの更新情報RSS