2024-05-02 17:33:05

 

 

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
45
46
47
48
49
50
using System.IO;
using System.Text;
using System.Linq;
using System.Reflection.PortableExecutable;
using System.Security.Cryptography;
 
namespace 연습장
{
    internal class Program
    {
        static StringBuilder sb = new StringBuilder();
        static void Main(string[] args)
        {
            using var reader = new StreamReader(Console.OpenStandardInput());
            using var print = new StreamWriter(Console.OpenStandardOutput());
 
            _9084_boj boj = new _9084_boj();
 
            boj.boj_9084();
 
        }
    }
        internal class _9084_boj
    {
        public void boj_9084()
        {
            int n = int.Parse(Console.ReadLine());
 
            for (int i = 0; i < n; i++)
            {
                int cnt = int.Parse(Console.ReadLine());
                int[] arr = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
                int num = int.Parse(Console.ReadLine());
 
                int[] dp = new int[num + 1];
                dp[0= 1;
                for (int j = 0; j < arr.Length; j++)
                {
                    for (int k = arr[j]; k <= num; k++)
                    {
                        dp[k] += dp[k - arr[j]];
                    }
                    
                }
                Console.WriteLine(dp[num]);
            }
        }
    }
}
    
cs

한번에 맞아서 오히려 당황했다