9375번: 패션왕 신해빈 (acmicpc.net)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace _230124_1
{
    class Program
    {
        static void Main(string[] args)
        {
            StreamReader sr = new StreamReader(Console.OpenStandardInput());
            StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
            List<int> resultList = new List<int>();
            

            int a = int.Parse(sr.ReadLine());
            for(int i = 0; i < a; i++)
            {
                int N = int.Parse(sr.ReadLine());
                Dictionary<string, int> dicCloth = new Dictionary<string, int>();

                for (int j = 0; j < N; j++)
                {
                    string[] arr = sr.ReadLine().ToString().Split(' ');
                    if (dicCloth.ContainsKey(arr[1]))
                    {
                        dicCloth[arr[1]]++;
                    }
                    else
                    {
                        dicCloth.Add(arr[1], 1);
                    }
                }

                int result = 1;
                foreach (var cloth in dicCloth.Values)
                {
                    result *= (cloth + 1);    //안 입는 경우를 고려하여 각 종류별 옷의 개수에 +1 해준 값을 곱함
                }

                resultList.Add(result - 1); // 알몸인 상태를 제외 
            }

            foreach(int result in resultList)
            {
                sw.WriteLine(result);
            }            

            sr.Close();
            sw.Close();
        }
    }
}

순열을 이해해도 조합공식이 이해가 안되는 문제...

'Algorithm > BOJ' 카테고리의 다른 글

C#) [BOJ] 1978 소수찾기  (0) 2023.01.25
C#) [BOJ] 2292 벌집 ★  (0) 2023.01.25
C#) [BOJ] 2461 대표 선수 ★★  (0) 2023.01.24
C#) [BOJ] 10867 중복 빼고 정렬하기  (0) 2023.01.24
C#) [BOJ] 1018 체스판 다시 칠하기  (0) 2023.01.23

+ Recent posts