Very egg pain of a problem, the topic itself is very simple, but the final output is so disgusting,
There are three points to note:
1.title Single Complex problem
2.title the number of spaces after a single complex is different
There should be a blank line between the 3.Case, but the last case can not have a blank line, this is too disgusting, began to never find ... Direct loop output return, always error PE,
The last is the code: easy to reach the party:
ImportJava.text.DecimalFormat;ImportJava.util.Scanner; Public classmain{ Public Static voidMain (String[]args) {intT,ca=0; Scanner s=NewScanner (system.in); for(T=s.nextint (); t>0; t--) { DoubleN,m,t,c; Double[]a =New Double[5]; N=s.nextdouble (); M=s.nextdouble (); T=s.nextdouble (); C=s.nextdouble (); a[0]=t*t*n*m; a[1]= (t-c) * (t-c) *n*m+ (c* (t-c) +c*c/4.0) *4+c* (t-c) * (n+m-4); a[2]=2*c* (t-c) *n*m-c* (t-c) * (n+m) +c*c* (n+m-2); a[4]=math.pi*c*c/4* (n-1) * (m-1); a[3]=a[0]-a[1]-a[2]-a[4]; System.out.println ("Case" + ++ca+ ":"); DecimalFormat DF=NewDecimalFormat ("0.0000"); for(inti=1;i<=4;i++) System.out.println ("Probability of Covering" +i+ (i==1? "tile =": "tiles =") +df.format (a[i]/a[0]*100.0) + "%"); if(t!=1) {System.out.println (); } } } }
POJ 3440 Java Spit Slot