SHOW:
|
|
- or go back to the newest paste.
| 1 | import java.util.Scanner; | |
| 2 | import java.lang.Math.*; | |
| 3 | import java.text.DecimalFormat; | |
| 4 | import java.text.NumberFormat; | |
| 5 | public class Solution | |
| 6 | {
| |
| 7 | public static void main(String args[]) | |
| 8 | {
| |
| 9 | Scanner sc = new Scanner(System.in); | |
| 10 | NumberFormat formatter=new DecimalFormat("#0.00");
| |
| 11 | double n = (double)sc.nextInt(); | |
| 12 | double math=0.0,physics=0.0,chem=0.0,i=0.0; | |
| 13 | double sum1=0.0,sum2=0.0,sum3=0.0,msum=0.0,psum=0.0; | |
| 14 | double csum=0.0,rmath_phy=0.0,sqsum_m=0.0,sqsum_p=0.0; | |
| 15 | double sqsum_c=0.0,rphy_chem=0.0,rchem_math=0.0; | |
| 16 | double prSum1=0.0,prSum2=0.0,prSum3=0.0; | |
| 17 | while(i++ <n){
| |
| 18 | math = sc.nextInt();physics = sc.nextInt();chem = sc.nextInt(); | |
| 19 | ||
| 20 | sum1+=math*physics; sum2+=physics*chem; sum3+=math*chem; | |
| 21 | ||
| 22 | msum+=math;psum+=physics;csum+=chem; | |
| 23 | ||
| 24 | sqsum_m+=math*math; sqsum_p+=physics*physics;sqsum_c+=chem*chem; | |
| 25 | ||
| 26 | } | |
| 27 | rmath_phy = (n*sum1-msum*psum)/(Math.sqrt(n*sqsum_m-msum*msum)*Math.sqrt(n*sqsum_p-(psum*psum))); | |
| 28 | rphy_chem = (n*sum2-psum*csum)/(Math.sqrt(n*sqsum_p-psum*psum)*Math.sqrt(n*sqsum_c-(csum*csum))); | |
| 29 | rchem_math =(n*sum3-csum*msum)/(Math.sqrt(n*sqsum_c-csum*csum)*Math.sqrt(n*sqsum_m-(msum*msum))); | |
| 30 | System.out.println(formatter.format(rmath_phy)); | |
| 31 | System.out.println(formatter.format(rphy_chem)); | |
| 32 | System.out.println(formatter.format(rchem_math)); | |
| 33 | } | |
| 34 | } |