[Offer收割]编程练习赛7 register

Ended

Participants:506

Verdict:Time Limit Exceeded
Score:10 / 100
Submitted:2016-08-28 13:48:57

Lang:Java

Edit
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
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
public class Main {
    public static int result = 0;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNext()) {
            String s = in.next();
            int[] num = parse(s);
            int sum = Integer.parseInt(s.substring(s.indexOf('='+ 1));
            Arrays.sort(num);
            int[] aaa = new int[num.length];
            for(int i = 0i < num.lengthi++) {
                aaa[num.length - i - 1= num[i];
            }
            DFS(aaaprepare(), 0sum);
            System.out.println(result);
        }
    }
    public static void DFS(int[] numHashMap<IntegerEdge> mapint indexint sum) {
        if(sum < 0return;
        if(index == num.length) {
            if(sum == 0result++;
            return;
        }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX