-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFructe.java
More file actions
39 lines (36 loc) · 1.17 KB
/
Fructe.java
File metadata and controls
39 lines (36 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
public class Fruct{
int x,y,z,q;
int tip;
Fruct(int tip, int x, int y, int z, int q){
this.x=x;
this.y=y;
this.z=z;
this.q=q;
this.tip=tip;
}
double calcDistanta(Fruct fruct){
return Math.sqrt(Math.pow(this.x-fruct.x,2)+Math.pow(this.y-fruct.y,2)+Math.pow(this.z-fruct.z,2)+Math.pow(this.q-fruct.q,2));
}
}
import java.util.*;
public class ECCPR{
public static void main(String [] args){
int n;
double min=0;
int out=0;
Scanner sc= new Scanner(System.in);
n=sc.nextInt();
Fruct fruct=new Fruct(sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt());
for(int i=0;i<n;i++){
Fruct fruct_dismin=new Fruct(sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt());
if(i==0){
min=fruct.calcDistanta(fruct_dismin);
out=fruct_dismin.tip;
}else if(min>fruct.calcDistanta(fruct_dismin)){
min=fruct.calcDistanta(fruct_dismin);
out=fruct_dismin.tip;
}
}
System.out.print(out);
}
}