강의로 돌아가기

### 수학을 잘하거나, 삽질을 잘 하거나

문제가 너무 어렵네요. 과연 이런 코딩을 기업 환경에서 얼마나 쓸지...

###### 작성중인 코드―Solution.cs
``````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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using System;
using System.Collections.Generic;

public class Solution {

public int solution(string numbers)
{
int nAnswer = 0;
int nResult = 0;
int nMod = 0;
int nMax = 0;

List<int> lstNumber = new List<int>(numbers.Length);
foreach (var vCh in numbers.ToCharArray())
{
}
lstNumber.Sort();

for (int i = lstNumber.Count - 1; i >= 0; --i)
{
nMax += (lstNumber[i] * (int)Math.Pow(10, i));
}

List<bool> lstPrimes = new List<bool>(GetPrimes(nMax));
List<int> lstPrimeDigit = new List<int>();

for (int k = 2; k < lstPrimes.Count; ++k)
{
if (lstPrimes[k] == false)
continue;

bool bIncludeNumber = true;
bool bIncludeDigit = false;

nResult = k;

lstPrimeDigit.Clear();

do
{
nMod = nResult % 10;
nResult /= 10;

} while (nResult > 0);

List<int> lstNumberTempo = new List<int>(lstNumber);

for (int i = 0; i < lstPrimeDigit.Count; ++i)
{
bIncludeDigit = false;
for (int j = 0; j < lstNumberTempo.Count; ++j)
{
if (lstPrimeDigit[i] == lstNumberTempo[j])
{
bIncludeDigit = true;
lstNumberTempo[j] = -1;
break;
}
}

bIncludeNumber &= bIncludeDigit;
if (!bIncludeNumber)
{
break;
}
}

if (bIncludeNumber)
}

}

bool[] GetPrimes(int nMax)
{
List<bool> lstPrimes = new List<bool>(nMax);

for (int i = 0; i <= nMax; ++i)

for (int i = 2; i <= nMax; ++i)
{
for (int j = i * 2; j <= nMax; j += i)
lstPrimes[j] = false;
}

return lstPrimes.ToArray();
}

}
``````