Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
对精度的要求感觉很高啊y通过x来计算 一直WA 最后y也用一大串表达式计算出来,AC了 晒一下龊代码。。。 import java.io.*; import java.math.*; import java.util.*; public class Main { public Main() { fin=new Scanner(System.in); work(); } private void work() { // TODO Auto-generated method stub int n=fin.nextInt(); while(n--!=0) { double x1=fin.nextDouble(); double y1=fin.nextDouble(); double z1=fin.nextDouble(); double x2=fin.nextDouble(); double y2=fin.nextDouble(); double z2=fin.nextDouble(); z1=-z1+90; z2=-z2+90; z1=Math.tan(z1/180*Math.PI)+0.000000000000001; z2=Math.tan(z2/180*Math.PI)+0.000000000000001; //System.out.println(z1+" "+z2); // y-y1=z1*(x-x1) // y-y2=z2*(x-x2) // z1*x-z1*x1+y1=z2*x-z2*x2+y2 // (z1-z2)*x=z1*x1-y1-z2*x2+y2 // (y-y1)/z1+x1=(y-y2)/z2+x2 // y/z1-y1/z1+x1=y/z2-y2/z2+x2 // y/z1-y/z2=y1/z1-x1-y2/z2+x2 // y*(1/z1-1/z2)=y1/z1-x1-y2/z2+x2 double ansx=(z1*x1-y1-z2*x2+y2)/(z1-z2); //double ansy=z1*(ansx-x1)+y1; double ansy=(y1/z1-x1-y2/z2+x2)/(1/z1-1/z2); System.out.printf("%.4f %.4f",ansx+0.00000000000001,ansy+0.00000000000001); System.out.println(); } } Scanner fin=null; public static void main(String[] args) { new Main(); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator