Huawei OD machine test Java [calculate weight]

topic

You have a few different weights, each with its own weight and quantity. How many different weight combinations can you get using these weights?

enter:

The first line gives the number of weight types n (1 ≤ n ≤ 10).
The second line lists the weight of each weight in order, and the weight range is (1 ≤ m ≤ 2000).
The third line lists the quantity of each weight in order, and the quantity range is (1 ≤ x ≤ 10).
Output:
Output a number representing the number of different weight combinations you can get.

Example:

Input:
2
1 2
2 1

Output:
5

Instructions:
With these weights, you can get weights 0, 1, 2, 3 and 4, a total of five different weights.

code

public class Main {
   
    
    
    public static int differentWeights(int n

Guess you like

Origin blog.csdn.net/wtswts1232/article/details/135448310