forked from damaohongtu/JavaInterview
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathWangYi_03.java
More file actions
44 lines (35 loc) · 1.14 KB
/
Copy pathWangYi_03.java
File metadata and controls
44 lines (35 loc) · 1.14 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
40
41
42
43
44
package BiShi;
import java.io.File;
import java.text.DecimalFormat;
import java.util.Scanner;
public class WangYi_03 {
public static void main(String[] args) throws Exception {
Scanner sc=new Scanner(new File("/home/mao/workspace/java/src/BiShi/wangyi_01"));
while(sc.hasNext()){
int n=sc.nextInt();
int[] students=new int[n];
int[] nums=new int[151];
for(int i=0;i<n;i++){
int tmp=sc.nextInt();
students[i]=tmp;
nums[tmp]++;
}
int person=sc.nextInt();
for(int j=0;j<person;j++){
int q=sc.nextInt();
int core=students[q-1];
int low=0;
for(int i=0;i<=core;i++){
low+=nums[i];
}
double rank=(low-1)/(n+0.0)*100;
String s=new DecimalFormat("#.000000").format(rank);
if (s.equals(".000000")){
System.out.println("0.000000");
}else{
System.out.println(s);
}
}
}
}
}