アットウィキロゴ

yrdfk

import java.awt.*;
import java.awt.event.*;

class tax extends Frame{

int s;
double pxs,cxs,cost;
double th[]=new double[101];
double x[]=new double[101];
double p[]=new double[101];

public static void main(String [] args) {
        tax f=new tax();
        f.setTitle("tax");
        f.setSize(700,700);
        f.setBackground(Color.yellow);
        f.setVisible(true);
    }

tax(){

for(s=1;s<101;s++){
th[s]=s;
}

cost=10;

op();

for(s=1;s<101;s++){
x[s]=d(th[s],pxs,cxs);
if(x[s]>0)p[s]=pxs*x[s]+cxs;
}

addWindowListener(new stopwin());
}


class stopwin extends WindowAdapter{
    public void windowClosing(WindowEvent we){System.exit(0);}
}  


public void paint(Graphics g){
int p1;
for(s=1;s<101;s++){
p1=(int)(0.1*p[s]);
g.fillRect(5*s,600-p1,5,600);
}

}


void op(){
int m,n;
double maxv,px,cx;
maxv=0;
pxs=0;
cxs=0;
for (m=10;m<100;m++){
for (n=1;n<100;n++){
px=m;
cx=10*n;
if (rev(th,px,cx,cost)>maxv)pxs=px;
if (rev(th,px,cx,cost)>maxv)cxs=cx;
if (rev(th,px,cx,cost)>maxv)maxv=rev(th,px,cx,cost);
}
}

}


public static double rev(double[] th,double p,double c,double cost){
double x1,r1,sumr;
int s;
sumr=0;
for(s=1;s<101;s++){
x1=d(th[s],p,c);
r1=(p-cost)*x1;
if(x1==0)r1=0;
sumr=sumr+r1;
}
return sumr;
}


public static double d(double th1,double p,double c){
double x1,u1;
x1=th1-p;
if(x1<0)x1=0;
u1=u(th1,x1)-p*x1-c;
if(u1<0)x1=0;
return x1;
}

public static double u(double th1,double x){
double u1;
u1=th1*x-0.5*x*x;
return u1;
}







}
最終更新:2011年07月14日 07:09