Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package ktgk2;
- import java.util.*;
- /**
- *
- * @author nguyenanhkiet
- * Khoang cach va tich vo huong
- */
- public class KTGK2 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- Scanner cin = new Scanner(System.in);
- int t = Integer.parseInt(cin.nextLine());
- while(t-->0){
- String s1 = cin.nextLine();
- String st1[] = s1.trim().split("\\s+");
- int amount1 = st1.length;
- double arr1[] = new double[amount1];
- for(int i = 0; i < amount1; i++){
- arr1[i] = Double.parseDouble(st1[i]);
- }
- String s2 = cin.nextLine();
- String st2[] = s2.trim().split("\\s+");
- int amount2 = st2.length;
- double arr2[] = new double[amount2];
- for(int i = 0; i < amount2; i++){
- arr2[i] = Double.parseDouble(st2[i]);
- }
- double kc = 0, tvh = 0;
- for(int i = 0; i < amount1; i++){
- kc = kc + ((arr1[i]-arr2[i])*(arr1[i]-arr2[i]));
- tvh = tvh + (arr1[i] * arr2[i]);
- }
- kc = Math.sqrt(kc);
- long res = (long)tvh;
- System.out.println(String.format("%.2f %d", kc, res));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement