Skip to content

Commit 6a7b159

Browse files
committed
📝 Post BOJ Solution.
1 parent d108ce7 commit 6a7b159

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
layout: single
3+
title: "[백준 10569] 다면체 (C#, C++) - soo:bak"
4+
date: "2025-04-14 20:25:24 +0900"
5+
description: 오일러의 정리를 활용하여 면의 개수를 계산하는 백준 10569번 다면체 문제의 C# 및 C++ 풀이와 해설
6+
---
7+
8+
## 문제 링크
9+
[10569번 - 다면체](https://www.acmicpc.net/problem/10569)
10+
11+
## 설명
12+
이 문제는 **오일러의 정리(Euler's formula)**를 이용하여, <br>
13+
주어진 정점과 간선 개수로부터 **면(Face)의 개수를 계산하는 문제**입니다.
14+
15+
오일러의 정리에 따르면:
16+
17+
$$
18+
V - E + F = 2
19+
$$
20+
21+
여기서 `V`는 정점(Vertex), `E`는 간선(Edge), `F`는 면(Face)입니다. <br>
22+
따라서 다음과 같이 유도할 수 있습니다:
23+
24+
$$
25+
F = 2 - V + E
26+
$$
27+
28+
---
29+
30+
## 접근법
31+
- 테스트 케이스마다 `V``E`를 입력받고,
32+
- 위 식에 따라 `F = 2 - V + E`를 계산하여 출력합니다.
33+
34+
---
35+
36+
## Code
37+
<b>[ C# ] </b>
38+
<br>
39+
40+
```csharp
41+
using System;
42+
43+
namespace Solution {
44+
class Program {
45+
static void Main(string[] args) {
46+
int t = int.Parse(Console.ReadLine()!);
47+
while (t-- > 0) {
48+
var parts = Console.ReadLine()!.Split();
49+
int v = int.Parse(parts[0]);
50+
int e = int.Parse(parts[1]);
51+
Console.WriteLine(2 - v + e);
52+
}
53+
}
54+
}
55+
}
56+
```
57+
58+
<br><br>
59+
<b>[ C++ ] </b>
60+
<br>
61+
62+
```cpp
63+
#include <bits/stdc++.h>
64+
65+
using namespace std;
66+
67+
int main() {
68+
ios::sync_with_stdio(false);
69+
cin.tie(nullptr);
70+
71+
int n; cin >> n;
72+
while (n--) {
73+
int vertex, edge; cin >> vertex >> edge;
74+
cout << 2 + edge - vertex << "\n";
75+
}
76+
77+
return 0;
78+
}
79+
```

0 commit comments

Comments
 (0)