JAVA TAX 04 04
class tax{
public static void main(String args[]){
double th[]= new double[101];
int s;
double tl;
double tr;
double ls;
double w;
double cs;
double ys;
double b1;
double b2;
double tr1;
double tr2;
double tr3;
double wel;
double maxwel;
double maxtl;
int t;
int n;
for (s=1;s<101;s++){
th[s]=0.02*s;
}
maxtl=0;
maxwel=-999;
for (n=20;n<45;n++){
tl=0.01*n;
tr1=0.01;
tr2=0.02;
tr=tr1;
b1=0;
for (s=1;s<101;s++){
w=(1-tl)*th[s];
ls=(w-tr)/(2*w);
if (ls<0){
ls=0;
}
ys=th[s]*ls;
cs=w*ls+tr;
b1=b1+ys-cs;
}
t=0;
while (t<100) {
tr=tr2;
b2=0;
for (s=1;s<101;s++){
w=(1-tl)*th[s];
ls=(w-tr)/(2*w);
if (ls<0){
ls=0;
}
ys=th[s]*ls;
cs=w*ls+tr;
b2=b2+ys-cs;
}
tr3=tr2-b2*(tr2-tr1)/(b2-b1);
tr1=tr2;
tr2=tr3;
b1=b2;
if (b2*b2<0.00001){
t=1000;
}
t=t+1;
}
tr=tr2;
wel=0;
for (s=1;s<101;s++){
w=(1-tl)*th[s];
ls=(w-tr)/(2*w);
if (ls<0){
ls=0;
}
cs=w*ls+tr;
wel=wel+ux(cs,ls);
}
if (wel>maxwel){
maxtl=tl;
}
if (wel>maxwel){
maxwel=wel;
}
}
System.out.println(maxtl);
}
static double ux(double c1,double l1){
double u1;
u1=Math.log(c1)+Math.log(1-l1);
return u1;
}
}
public static void main(String args[]){
double th[]= new double[101];
int s;
double tl;
double tr;
double ls;
double w;
double cs;
double ys;
double b1;
double b2;
double tr1;
double tr2;
double tr3;
double wel;
double maxwel;
double maxtl;
int t;
int n;
for (s=1;s<101;s++){
th[s]=0.02*s;
}
maxtl=0;
maxwel=-999;
for (n=20;n<45;n++){
tl=0.01*n;
tr1=0.01;
tr2=0.02;
tr=tr1;
b1=0;
for (s=1;s<101;s++){
w=(1-tl)*th[s];
ls=(w-tr)/(2*w);
if (ls<0){
ls=0;
}
ys=th[s]*ls;
cs=w*ls+tr;
b1=b1+ys-cs;
}
t=0;
while (t<100) {
tr=tr2;
b2=0;
for (s=1;s<101;s++){
w=(1-tl)*th[s];
ls=(w-tr)/(2*w);
if (ls<0){
ls=0;
}
ys=th[s]*ls;
cs=w*ls+tr;
b2=b2+ys-cs;
}
tr3=tr2-b2*(tr2-tr1)/(b2-b1);
tr1=tr2;
tr2=tr3;
b1=b2;
if (b2*b2<0.00001){
t=1000;
}
t=t+1;
}
tr=tr2;
wel=0;
for (s=1;s<101;s++){
w=(1-tl)*th[s];
ls=(w-tr)/(2*w);
if (ls<0){
ls=0;
}
cs=w*ls+tr;
wel=wel+ux(cs,ls);
}
if (wel>maxwel){
maxtl=tl;
}
if (wel>maxwel){
maxwel=wel;
}
}
System.out.println(maxtl);
}
static double ux(double c1,double l1){
double u1;
u1=Math.log(c1)+Math.log(1-l1);
return u1;
}
}
このwikiの更新情報RSS