forked from damaohongtu/JavaInterview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShopee_02.java
More file actions
41 lines (35 loc) · 972 Bytes
/
Shopee_02.java
File metadata and controls
41 lines (35 loc) · 972 Bytes
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
package BiShi;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
/**
* @Classname Shopee_02
* @Description TODO
* @Date 19-7-27 下午6:53
* @Created by mao<[email protected]>
*/
public class Shopee_02 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
while(sc.hasNext()){
int count=sc.nextInt();
int target=sc.nextInt();
ArrayList<Integer> nums=new ArrayList<>();
for(int i=0;i<count;i++){
nums.add(sc.nextInt());
}
Collections.sort(nums);
count=0;
for(int i=0;i<count;i++){
int tmp=0;
for(int j=i;j<count;j++){
tmp=tmp+nums.get(j);
if(tmp==target){
count++;
}
}
}
System.out.println(count);
}
}
}