forked from damaohongtu/JavaInterview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain_1.java
More file actions
44 lines (41 loc) · 1.15 KB
/
Main_1.java
File metadata and controls
44 lines (41 loc) · 1.15 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 ByteDancePreparation;
import java.io.File;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
/**
* @Author MaoTian
* @Classname Main_1
* @Description TODO
* 6
* -2 0 1 2 3 6
* 2
* @Version 1.0
* @Created by mao<[email protected]>
*/
public class Main_1 {
public static void main(String[] args)throws Exception {
Scanner sc =new Scanner(new File("/home/mao/workspace/面试/JavaGuide/JavaInterview/java/src/ByteDancePreparation/main_1"));
//Scanner sc =new Scanner(System.in);
while(sc.hasNext()){
int n=sc.nextInt();
int[] nums=new int[n];
for (int i = 0; i <n ; i++) {
nums[i]=sc.nextInt();
}
int target=sc.nextInt();
int res=0;
for (int i=0;i<n-2;i++){
for (int j=i+1;j<n-1;j++){
for (int k = j+1; k <n ; k++) {
if(nums[i]+nums[j]+nums[k]<target){
res++;
}
}
}
}
System.out.println(res);
}
}
}