From 01d7835099d314972adab111134c25864ee0d9eb Mon Sep 17 00:00:00 2001 From: EUNA-319 <81363864+EUNA-319@users.noreply.github.com> Date: Sun, 12 Sep 2021 09:02:02 +0900 Subject: [PATCH 01/24] EUNA-319 boj11279 --- WEEK1-B/EUNA-319/boj11279.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 WEEK1-B/EUNA-319/boj11279.cpp diff --git a/WEEK1-B/EUNA-319/boj11279.cpp b/WEEK1-B/EUNA-319/boj11279.cpp new file mode 100644 index 00000000..03ff9f9f --- /dev/null +++ b/WEEK1-B/EUNA-319/boj11279.cpp @@ -0,0 +1,30 @@ +#include +#include +using namespace std; + +int n; // 입력받을 정수의 개수 +priority_queue pq; +int main() { + + cin.sync_with_stdio(0); + cin.tie(0); + + cin >> n; + for (int i=0;i> x; + if (x == 0) { //x가 0이라면 (0이 입력된 시점에서의 가장 큰 값을 출력하기 때문) + if (pq.empty()) cout << "0\n"; + // queue가 비어있을 경우 0 출력 + else { + cout << pq.top() << "\n"; + pq.pop(); + // 가장 위에 들어가있는 값을 출력 + // pop()을 해주면 queue의 선입선출 특징으로 맨위의 값이 나오게 됨 + } + } else { // x가 0이 아니라면 + pq.push(x); // 입력한 숫자를 priority_queue에 삽입 + } + } + return 0; +} \ No newline at end of file From d7853b8be24de94fbcc90ec60b44bc2437ac77f3 Mon Sep 17 00:00:00 2001 From: EUNA-319 <81363864+EUNA-319@users.noreply.github.com> Date: Thu, 16 Sep 2021 10:06:00 +0900 Subject: [PATCH 02/24] EUNA-319 boj2752 --- WEEK2-B/EUNA-319/boj2752.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 WEEK2-B/EUNA-319/boj2752.cpp diff --git a/WEEK2-B/EUNA-319/boj2752.cpp b/WEEK2-B/EUNA-319/boj2752.cpp new file mode 100644 index 00000000..98a5ad7a --- /dev/null +++ b/WEEK2-B/EUNA-319/boj2752.cpp @@ -0,0 +1,33 @@ +#include +using namespace std; + +void sorting(int* arr); + +int main() { + int v[3]; + int i=0, num; + while(i<3){ // 3개의 수 입력받기 + cin>>num; + v[i]=num; + i++; + } + sorting(v); +} + +void sorting(int* arr){ // 포인터로 함수 인자 전달 + int temp; // 수를 바꿀 때 사용 + for(int i=0;i<2;i++){ // 앞에 있는 수가 뒤에 있는 수 보다 작다면 계속해서 뒤로 밀림 + for(int j=i+1;j<3;j++){ // i보다 큰 숫자들에 대해 비교 반복 + if(arr[i]>arr[j]){ + temp=arr[i]; + arr[i]=arr[j]; + arr[j]=temp; + } + } + } + for(int i=0;i<3;i++) { + cout< Date: Thu, 16 Sep 2021 10:23:03 +0900 Subject: [PATCH 03/24] EUNA-319 boj2959 --- WEEK2-B/EUNA-319/boj2959.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 WEEK2-B/EUNA-319/boj2959.cpp diff --git a/WEEK2-B/EUNA-319/boj2959.cpp b/WEEK2-B/EUNA-319/boj2959.cpp new file mode 100644 index 00000000..14750b9c --- /dev/null +++ b/WEEK2-B/EUNA-319/boj2959.cpp @@ -0,0 +1,29 @@ +#include +using namespace std; + +int sorting(int* arr); + +int main() { + int v[4]; + int i=0, num; + while(i<4){ // 4개의 수 입력받기 + cin>>num; + v[i]=num; + i++; + } + cout<arr[j]){ + temp=arr[i]; + arr[i]=arr[j]; + arr[j]=temp; + } + } + } + return arr[0]*arr[2]; // 정렬된 4개의 수 중 인덱스 0번쨰와 2번째의 수를 곱한 것이 거북이가 움직인 거리로 만들 수 있는 직사각형의 크기 +} \ No newline at end of file From 4464aca14527468edfdb303e5ed7750892901193 Mon Sep 17 00:00:00 2001 From: EUNA-319 <81363864+EUNA-319@users.noreply.github.com> Date: Thu, 16 Sep 2021 10:38:17 +0900 Subject: [PATCH 04/24] =?UTF-8?q?EUNA-319=20boj2959=20=EC=95=8C=EA=B3=A0?= =?UTF-8?q?=EB=A6=AC=EC=A6=98=20=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WEEK2-B/EUNA-319/README.md | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 WEEK2-B/EUNA-319/README.md diff --git a/WEEK2-B/EUNA-319/README.md b/WEEK2-B/EUNA-319/README.md new file mode 100644 index 00000000..eb5d2d2b --- /dev/null +++ b/WEEK2-B/EUNA-319/README.md @@ -0,0 +1,37 @@ +## 백준 2959 알고리즘 정리 ## +
+ +### 사용한 알고리즘 : Buble Sotring ### + +- 서로 인접한 두 원소를 검사하여 정렬하는 알고리즘
+  -> 인접한 2개의 레코드를 비교하여 크기가 순서대로 되어 있지 않으면 서로 교환함 +- 오름차순을 기준으로 정렬 +- 선택 정렬과 기본 개념이 유사함 +

+ +### 버블 정렬의 구현 ### +- 순회할 원소의 개수가 하나씩 줄어든다는 점 + ```c++ + // Bubble Sort +for (i = 0; i < N; i++) { + for (j = 0; j < N-(i+1); j++) { + if (data[j] > data[j+1]) { + // 자리교환 + temp = data[j+1]; + data[j+1] = data[j]; + data[j] = temp; + } + } + } + + ``` + +### 문제 풀 때 생각한 flow ### +- 단순하게 정렬해서 출력하면 됨 이때 띄어쓰기 횟수에 주의함 +

+ +### 새롭게 공부한 내용 ### +- 내가 구현한 방법이 버블 정렬과 유사하다는 점을 알 수 있었음 +- 이미 c++에는 정렬 알고리즘이 있음 -> C++ STL sort() +- sort(): 기본적으로 오름차순 정렬을 수행
+   -> 배열의 시작점 주소와 마지막 주소+1을 인자로 주면 됨 \ No newline at end of file From 1ca419210a79d530ffb844667910ecd19490fcbe Mon Sep 17 00:00:00 2001 From: EUNA-319 <81363864+EUNA-319@users.noreply.github.com> Date: Fri, 17 Sep 2021 12:03:00 +0900 Subject: [PATCH 05/24] EUNA-319 boj2693 --- WEEK2-B/EUNA-319/boj2693.cpp | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 WEEK2-B/EUNA-319/boj2693.cpp diff --git a/WEEK2-B/EUNA-319/boj2693.cpp b/WEEK2-B/EUNA-319/boj2693.cpp new file mode 100644 index 00000000..892b9025 --- /dev/null +++ b/WEEK2-B/EUNA-319/boj2693.cpp @@ -0,0 +1,44 @@ +#include +#include +using namespace std; + +class List{ +public: + int age; + string name; +}; + +void sorting(List *list); + +int main() { + int tc; + cin>>tc; + List *list=new List[tc]; + + for(int i=0; i>list[i].age>>list[i].name; + } + sorting(list,list+tc); + for(int i=0;ilist[j].age){ + temp1=list[i].age; + temp2=list[i].name; + list[i].age=list[j].age; + list[i].name=list[j].name; + list[j].age=temp1; + list[j].name=temp2; + } + } + } +} \ No newline at end of file From a5b443470f3e3ed5afd71b72b1e2e4d2369fd04b Mon Sep 17 00:00:00 2001 From: EUNA-319 <81363864+EUNA-319@users.noreply.github.com> Date: Fri, 17 Sep 2021 12:47:30 +0900 Subject: [PATCH 06/24] EUNA-319 boj10867 --- WEEK2-B/EUNA-319/boj10867.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 WEEK2-B/EUNA-319/boj10867.cpp diff --git a/WEEK2-B/EUNA-319/boj10867.cpp b/WEEK2-B/EUNA-319/boj10867.cpp new file mode 100644 index 00000000..07a52f17 --- /dev/null +++ b/WEEK2-B/EUNA-319/boj10867.cpp @@ -0,0 +1,17 @@ +#include +#include +using namespace std; + +int main() { + int tc; + cin>>tc; + int *a = new int[tc]; + for(int i=0;i>a[i]; + } + sort(a,a+tc); + cout< Date: Fri, 17 Sep 2021 13:49:39 +0900 Subject: [PATCH 07/24] EUNA-319 boj2693 --- WEEK2-B/EUNA-319/boj2693.cpp | 38 ++++-------------------------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/WEEK2-B/EUNA-319/boj2693.cpp b/WEEK2-B/EUNA-319/boj2693.cpp index 892b9025..28789416 100644 --- a/WEEK2-B/EUNA-319/boj2693.cpp +++ b/WEEK2-B/EUNA-319/boj2693.cpp @@ -2,43 +2,13 @@ #include using namespace std; -class List{ -public: - int age; - string name; -}; - -void sorting(List *list); - int main() { + int a[10]; int tc; cin>>tc; - List *list=new List[tc]; - - for(int i=0; i>list[i].age>>list[i].name; - } - sorting(list,list+tc); for(int i=0;ilist[j].age){ - temp1=list[i].age; - temp2=list[i].name; - list[i].age=list[j].age; - list[i].name=list[j].name; - list[j].age=temp1; - list[j].name=temp2; - } - } + scanf("%d %d %d %d %d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&a[4],&a[5],&a[6],&a[7],&a[8],&a[9]); + sort(a,a+10); + cout< Date: Fri, 17 Sep 2021 14:16:52 +0900 Subject: [PATCH 08/24] EUNA-319 boj10814 --- WEEK2-B/EUNA-319/boj10814.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 WEEK2-B/EUNA-319/boj10814.cpp diff --git a/WEEK2-B/EUNA-319/boj10814.cpp b/WEEK2-B/EUNA-319/boj10814.cpp new file mode 100644 index 00000000..09aa7db4 --- /dev/null +++ b/WEEK2-B/EUNA-319/boj10814.cpp @@ -0,0 +1,33 @@ +#include +#include +#include +using namespace std; + +struct List{ + int age; + string name; +}; + +bool compare(const List &i, const List &j){ + return i.age>tc; + vector person; + List list; + + for(int i=0; i>list.age>>list.name; + person.push_back(list); + } + stable_sort(person.begin(),person.end(),compare); + + for(int i=0;i Date: Sat, 25 Sep 2021 15:12:48 +0900 Subject: [PATCH 09/24] EUNA-319 3week readme --- WEEK3-B/EUNA-319/README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 WEEK3-B/EUNA-319/README.md diff --git a/WEEK3-B/EUNA-319/README.md b/WEEK3-B/EUNA-319/README.md new file mode 100644 index 00000000..9d92527e --- /dev/null +++ b/WEEK3-B/EUNA-319/README.md @@ -0,0 +1,23 @@ +## 백준 5086 알고리즘 정리 ## +
+ +### 사용한 알고리즘 : 수학, 구현 ### + +### 이번 문제에서 사용한 수학 개념: 배수와 약수 ### +- a와 b가 있을 때 + >> a가 b의 약수이면 b는 a의 배수임 + >> a가 b의 배수이면 b는 a의 약수임 + + ```c++ + string trans(unsigned int a, unsigned int b){ + if(b%a==0) return "factor"; + else if(a%b==0) return "multiple"; + else return "neither"; + } + + ``` + +### 문제 풀 때 생각한 flow ### +- 단순하게 배수와 약수의 관계를 구분하는 trans 함수를 만들어 문제를 해결해봄 +

+ From 12732a3a2f395306b4b159b478215c49b45fc11b Mon Sep 17 00:00:00 2001 From: fascinatioeuna <81363864+EUNA-319@users.noreply.github.com> Date: Sat, 25 Sep 2021 15:23:33 +0900 Subject: [PATCH 10/24] Delete WEEK3-B/EUNA-319 directory --- WEEK3-B/EUNA-319/README.md | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 WEEK3-B/EUNA-319/README.md diff --git a/WEEK3-B/EUNA-319/README.md b/WEEK3-B/EUNA-319/README.md deleted file mode 100644 index 9d92527e..00000000 --- a/WEEK3-B/EUNA-319/README.md +++ /dev/null @@ -1,23 +0,0 @@ -## 백준 5086 알고리즘 정리 ## -
- -### 사용한 알고리즘 : 수학, 구현 ### - -### 이번 문제에서 사용한 수학 개념: 배수와 약수 ### -- a와 b가 있을 때 - >> a가 b의 약수이면 b는 a의 배수임 - >> a가 b의 배수이면 b는 a의 약수임 - - ```c++ - string trans(unsigned int a, unsigned int b){ - if(b%a==0) return "factor"; - else if(a%b==0) return "multiple"; - else return "neither"; - } - - ``` - -### 문제 풀 때 생각한 flow ### -- 단순하게 배수와 약수의 관계를 구분하는 trans 함수를 만들어 문제를 해결해봄 -

- From b36e304a6d86a5b1b35f6595e3d71a8404d0a9a1 Mon Sep 17 00:00:00 2001 From: EUNA-319 <81363864+EUNA-319@users.noreply.github.com> Date: Sun, 26 Sep 2021 01:39:26 +0900 Subject: [PATCH 11/24] EUNA-319 --- WEEK3-B/EUNA-319/README.md | 21 +++++++++++++++++ WEEK3-B/EUNA-319/boj15953.cpp | 43 +++++++++++++++++++++++++++++++++++ WEEK3-B/EUNA-319/boj2941.cpp | 29 +++++++++++++++++++++++ WEEK3-B/EUNA-319/boj5086.cpp | 24 +++++++++++++++++++ 4 files changed, 117 insertions(+) create mode 100644 WEEK3-B/EUNA-319/README.md create mode 100644 WEEK3-B/EUNA-319/boj15953.cpp create mode 100644 WEEK3-B/EUNA-319/boj2941.cpp create mode 100644 WEEK3-B/EUNA-319/boj5086.cpp diff --git a/WEEK3-B/EUNA-319/README.md b/WEEK3-B/EUNA-319/README.md new file mode 100644 index 00000000..121c5237 --- /dev/null +++ b/WEEK3-B/EUNA-319/README.md @@ -0,0 +1,21 @@ +## 백준 5086 알고리즘 정리 ## +
+ +### 사용한 알고리즘 : 산술 ### + +- 배수와 약수의 관계: a와 b + --> a가 b의 약수일 때 b는 a의 배수 + --> a가 b의 배수일 때 b는 a의 약수 +

+ +### 구현 ### +- 배수와 약수의 관계를 파악하여 품 + ```c++ +string trans(unsigned int a, unsigned int b){ + if(b%a==0) return "factor"; + else if(a%b==0) return "multiple"; + else return "neither"; +} + + ``` + diff --git a/WEEK3-B/EUNA-319/boj15953.cpp b/WEEK3-B/EUNA-319/boj15953.cpp new file mode 100644 index 00000000..4b9fd687 --- /dev/null +++ b/WEEK3-B/EUNA-319/boj15953.cpp @@ -0,0 +1,43 @@ +#include +using namespace std; + +unsigned int cal(unsigned int a, unsigned b); + + +int main() { + unsigned int n, a=0, b=0; + cin.sync_with_stdio(0); + cin.tie(0); + + cin>>n; + cin.ignore(); + for(int i=0;i>a>>b; + cin.ignore(); + cout<21||a==0) a=0; //본선 진출 X와 순위권 X를 고려 + else{ + if(a==1) a=5000000; + else if(3>=a) a=3000000; + else if(6>=a) a=2000000; + else if(10>=a) a= 500000; + else if(15>=a) a=300000; + else a=100000; + } + + if(b>31||b==0) b=0; // 본선 진출 X와 순위권 X를 고려 + else{ + if(b==1) b=5120000; + else if(3>=b) b=2560000; + else if(7>=b) b=1280000; + else if(15>=b) b= 640000; + else b=320000; + } + + return a+b; +} diff --git a/WEEK3-B/EUNA-319/boj2941.cpp b/WEEK3-B/EUNA-319/boj2941.cpp new file mode 100644 index 00000000..648113e0 --- /dev/null +++ b/WEEK3-B/EUNA-319/boj2941.cpp @@ -0,0 +1,29 @@ +#include +using namespace std; + +int main() { + string str; + int count = 0; + cin>>str; + for (int i = 0; i +#include +using namespace std; + +string trans(unsigned int a, unsigned int b); + +int main() { + unsigned int a, b; + cin.sync_with_stdio(0); + cin.tie(0); + + do { + cin >> a >> b; + if(a==0&&b==0) return 0; + cout << trans(a, b)< Date: Sun, 26 Sep 2021 01:59:42 +0900 Subject: [PATCH 12/24] EUNA-319 boj11723 --- WEEK3-B/EUNA-319/boj11723.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 WEEK3-B/EUNA-319/boj11723.cpp diff --git a/WEEK3-B/EUNA-319/boj11723.cpp b/WEEK3-B/EUNA-319/boj11723.cpp new file mode 100644 index 00000000..6a82c60d --- /dev/null +++ b/WEEK3-B/EUNA-319/boj11723.cpp @@ -0,0 +1,34 @@ +#include +#include +using namespace std; +bool checkNum[21]; +int main() { + ios_base::sync_with_stdio(0); + cin.tie(); + int n; + cin>>n; + for(int i=0;i>str; + if (str=="add") { + cin>>x; + checkNum[x]=true; + } else if (str=="remove") { + cin>>x; + checkNum[x]=false; + } else if (str=="check") { + cin>>x; + checkNum[x] ? (puts("1")) : (puts("0")); + } else if (str=="toggle") { + cin>>x; + checkNum[x] ? (checkNum[x]=false) : (checkNum[x]=true); + } else if (str=="all") { + memset(checkNum, true, sizeof(checkNum)); + } else { + memset(checkNum, false, sizeof(checkNum)); + } + } + return 0; +} + From 7c3ca087c0d621c5a513130a73b47a6049b82d75 Mon Sep 17 00:00:00 2001 From: EUNA-319 <81363864+EUNA-319@users.noreply.github.com> Date: Tue, 28 Sep 2021 19:05:18 +0900 Subject: [PATCH 13/24] =?UTF-8?q?EUNA-319=203=EC=A3=BC=EC=B0=A8=20?= =?UTF-8?q?=EC=A0=95=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WEEK3-B/EUNA-319/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WEEK3-B/EUNA-319/README.md b/WEEK3-B/EUNA-319/README.md index 121c5237..10a20f99 100644 --- a/WEEK3-B/EUNA-319/README.md +++ b/WEEK3-B/EUNA-319/README.md @@ -1,12 +1,12 @@ ## 백준 5086 알고리즘 정리 ## -
+

### 사용한 알고리즘 : 산술 ### - 배수와 약수의 관계: a와 b --> a가 b의 약수일 때 b는 a의 배수 --> a가 b의 배수일 때 b는 a의 약수 -

+


### 구현 ### - 배수와 약수의 관계를 파악하여 품 From add1dfda0eba25d3f151e4bdaa606e66dc93843f Mon Sep 17 00:00:00 2001 From: EUNA-319 <81363864+EUNA-319@users.noreply.github.com> Date: Tue, 28 Sep 2021 21:58:58 +0900 Subject: [PATCH 14/24] EUNA-319 boj1790 --- WEEK3-B/EUNA-319/boj1790.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 WEEK3-B/EUNA-319/boj1790.cpp diff --git a/WEEK3-B/EUNA-319/boj1790.cpp b/WEEK3-B/EUNA-319/boj1790.cpp new file mode 100644 index 00000000..6a82c60d --- /dev/null +++ b/WEEK3-B/EUNA-319/boj1790.cpp @@ -0,0 +1,34 @@ +#include +#include +using namespace std; +bool checkNum[21]; +int main() { + ios_base::sync_with_stdio(0); + cin.tie(); + int n; + cin>>n; + for(int i=0;i>str; + if (str=="add") { + cin>>x; + checkNum[x]=true; + } else if (str=="remove") { + cin>>x; + checkNum[x]=false; + } else if (str=="check") { + cin>>x; + checkNum[x] ? (puts("1")) : (puts("0")); + } else if (str=="toggle") { + cin>>x; + checkNum[x] ? (checkNum[x]=false) : (checkNum[x]=true); + } else if (str=="all") { + memset(checkNum, true, sizeof(checkNum)); + } else { + memset(checkNum, false, sizeof(checkNum)); + } + } + return 0; +} + From fdf2df8cbc79ca6b007f1cfaed59210be0a4c28e Mon Sep 17 00:00:00 2001 From: EUNA-319 <81363864+EUNA-319@users.noreply.github.com> Date: Tue, 28 Sep 2021 22:10:38 +0900 Subject: [PATCH 15/24] EUNA-319 boj1790 --- WEEK3-B/EUNA-319/boj1790.cpp | 53 ++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/WEEK3-B/EUNA-319/boj1790.cpp b/WEEK3-B/EUNA-319/boj1790.cpp index 6a82c60d..ae2dc00f 100644 --- a/WEEK3-B/EUNA-319/boj1790.cpp +++ b/WEEK3-B/EUNA-319/boj1790.cpp @@ -1,34 +1,33 @@ #include -#include using namespace std; -bool checkNum[21]; + +int length(unsigned int a); + int main() { - ios_base::sync_with_stdio(0); - cin.tie(); - int n; - cin>>n; - for(int i=0;i>str; - if (str=="add") { - cin>>x; - checkNum[x]=true; - } else if (str=="remove") { - cin>>x; - checkNum[x]=false; - } else if (str=="check") { - cin>>x; - checkNum[x] ? (puts("1")) : (puts("0")); - } else if (str=="toggle") { - cin>>x; - checkNum[x] ? (checkNum[x]=false) : (checkNum[x]=true); - } else if (str=="all") { - memset(checkNum, true, sizeof(checkNum)); - } else { - memset(checkNum, false, sizeof(checkNum)); + int n,k,len=0,i,j; + cin>>n>>k; + + for(i=1;i<=n;i++) { + len += length(i); + if (len >= k) break; + } + if(len == k){ + cout<len) cout<< -1; + else{ + for(j=0; j0){ + sum++; + a/=10; + } + return sum; +} From e46d7b900dd63398bb23d811525de07a926a22c5 Mon Sep 17 00:00:00 2001 From: EUNA-319 <81363864+EUNA-319@users.noreply.github.com> Date: Sun, 3 Oct 2021 00:37:08 +0900 Subject: [PATCH 16/24] EUNA-319 boj13706 --- WEEK4-B/EUNA-319/boj13706.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 WEEK4-B/EUNA-319/boj13706.cpp diff --git a/WEEK4-B/EUNA-319/boj13706.cpp b/WEEK4-B/EUNA-319/boj13706.cpp new file mode 100644 index 00000000..ba651f09 --- /dev/null +++ b/WEEK4-B/EUNA-319/boj13706.cpp @@ -0,0 +1,23 @@ +#include +#include +using namespace std; + +int main() { + int n; + cin>>n; + int low = 1; + int high = n; + int mid; + + while (1) { + mid = (low + high); // 2 + if(pow(mid,2) == n) { + cout< n) + high = mid - 1; + else if(pow(mid,2) Date: Sun, 3 Oct 2021 00:37:54 +0900 Subject: [PATCH 17/24] EUNA-319 boj10829 --- WEEK4-B/EUNA-319/boj10829.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 WEEK4-B/EUNA-319/boj10829.cpp diff --git a/WEEK4-B/EUNA-319/boj10829.cpp b/WEEK4-B/EUNA-319/boj10829.cpp new file mode 100644 index 00000000..80c09109 --- /dev/null +++ b/WEEK4-B/EUNA-319/boj10829.cpp @@ -0,0 +1,19 @@ +#include +#include + +using namespace std; + +int main() { + stack s; + long a; + cin>>a; + do{ + s.push(a%2); + a/=2; + }while(a!=0); + + do{ + cout< Date: Sun, 3 Oct 2021 00:51:33 +0900 Subject: [PATCH 18/24] EUNA-319 boj10829 --- WEEK4-B/EUNA-319/boj10829.cpp | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/WEEK4-B/EUNA-319/boj10829.cpp b/WEEK4-B/EUNA-319/boj10829.cpp index 80c09109..16a83bf3 100644 --- a/WEEK4-B/EUNA-319/boj10829.cpp +++ b/WEEK4-B/EUNA-319/boj10829.cpp @@ -1,19 +1,18 @@ #include -#include - using namespace std; +void to_bin(long number) { + if (number == 0 || number == 1) { + cout << number; + } + else { + to_bin(number / 2); + cout << number % 2; + } +} + int main() { - stack s; long a; cin>>a; - do{ - s.push(a%2); - a/=2; - }while(a!=0); - - do{ - cout< Date: Sun, 3 Oct 2021 01:43:50 +0900 Subject: [PATCH 19/24] EUNA319 - 4week readme --- WEEK4-B/EUNA-319/README.md | 52 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 WEEK4-B/EUNA-319/README.md diff --git a/WEEK4-B/EUNA-319/README.md b/WEEK4-B/EUNA-319/README.md new file mode 100644 index 00000000..337a0524 --- /dev/null +++ b/WEEK4-B/EUNA-319/README.md @@ -0,0 +1,52 @@ +## 분할 정복 공부 ## +

+ +### 재귀 ### +- 자기 자신을 호출하는 함수 +- 자신의 복사본을 호출하여 더 작은 문제를 풀게함으로써 문제를 해결 +- 기본 경우: 함수가 재귀 호출을 하지 않는 것 +- 재귀 경우: 자기 자신을 호출해서 하위 작업을 수행하는 것 +

+ +### 이분 탐색 ### +- 탐색 기법 중 하나로 원하는 탐색 범위를 두 부분으로 분할해서 찾는 방식 +- 원래의 전부를 탐색하는 속도에 비해 빠름 +- left, right, mid 값으로 탐색하는 것 +- mid의 값은 (left+right)/2으로 잡아주고 검색하고자 하는 값과 mid를 비교 +- 조건: 정렬이 되어있어야 함 + ```c++ + #include + int main(void){ + + int findN; + int result = 0; + //처음int는 다음 정점 마지막 int 값어치 + + int A[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 15 }; + + scanf("%d", &findN); + int left = 0, right = 9; + + + while (left <= right){ + + int mid = (left + right) / 2; + if (A[mid] > findN) + right = mid - 1; + else if (A[mid] < findN) + left = mid + 1; + else + { + result = mid; + break; + } + + } + + printf("%d\n", result); + + return 0; + } + ``` + + From 833ba07087bbd8fd8d788a8601f123832454cec4 Mon Sep 17 00:00:00 2001 From: EUNA-319 <81363864+EUNA-319@users.noreply.github.com> Date: Sun, 3 Oct 2021 01:55:48 +0900 Subject: [PATCH 20/24] EUNA-319 boj1769 --- WEEK4-B/EUNA-319/boj1769.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 WEEK4-B/EUNA-319/boj1769.cpp diff --git a/WEEK4-B/EUNA-319/boj1769.cpp b/WEEK4-B/EUNA-319/boj1769.cpp new file mode 100644 index 00000000..621d788d --- /dev/null +++ b/WEEK4-B/EUNA-319/boj1769.cpp @@ -0,0 +1,35 @@ +#include +#include +#include +using namespace std; +void cal(char num[]); + +int main() { + cin.sync_with_stdio(0); + cin.tie(0); + char num[1000001]; + cin >> num; + cal(num); +} + +void cal(char num[]) +{ + int count = 0; + int sum; + while(strlen(num)>1) + { + sum = 0; + for (int i = 0; i < strlen(num); i++) + { + sum += num[i] - '0'; + } + sprintf(num,"%d",sum); + count++; + } + cout << count<< endl; + + if (stoi(num) != 3&&stoi(num)!=6&&stoi(num)!=9) + cout << "NO"; + else + cout << "YES"; +} From d145075010949744606b1b10db8fd081ff0f72ba Mon Sep 17 00:00:00 2001 From: EUNA-319 <81363864+EUNA-319@users.noreply.github.com> Date: Sun, 31 Oct 2021 01:11:53 +0900 Subject: [PATCH 21/24] EUNA-319 boj2630 --- WEEK4-B/EUNA-319/boj2630.cpp | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 WEEK4-B/EUNA-319/boj2630.cpp diff --git a/WEEK4-B/EUNA-319/boj2630.cpp b/WEEK4-B/EUNA-319/boj2630.cpp new file mode 100644 index 00000000..f4c01581 --- /dev/null +++ b/WEEK4-B/EUNA-319/boj2630.cpp @@ -0,0 +1,43 @@ +// BOJ 2630번 : 색종이 만들기 +#include +using namespace std; +void dfs(int x, int y, int size); +int arr[128][128]; +int white = 0, blue = 0; + +int main() { + int n; + cin >> n; + for(int i = 0; i < n; i++) + for(int j = 0; j < n; j++) + cin >> arr[i][j]; // 배열 입력받기 + + dfs(0, 0, n); + cout << white << "\n" << blue << "\n"; +} + +void dfs(int x, int y, int n){ + bool w = true, b = true; // w와 b 초깃값 true + for(int i = x; i < x + n; i++){ // x + n까지 반복 + for(int j = y; j < y + n; j++){ // y + n까지 반복 + if(arr[i][j] == 1) // 만약 하얀색이라면 + w = false; // w를 false로 + if(arr[i][j] == 0) // 파란색이라면 + b = false; // b를 false로 + } + } + if(w == true){ // w가 true라면 (하얀색으로 채워진 것) + white++; // white 증가 + return; + } + if(b == true){ // b가 true라면 (파란색으로 채워진 것) + blue++; // blue 증가 + return; + } + + // 재귀호출 + dfs(x, y, n / 2); + dfs(x, y + n / 2, n / 2); + dfs(x + n / 2, y, n / 2); + dfs(x + n / 2, y + n / 2, n / 2); +} \ No newline at end of file From f3e567864079ce0578f0a64156ab1b6bcf56f0df Mon Sep 17 00:00:00 2001 From: EUNA-319 <81363864+EUNA-319@users.noreply.github.com> Date: Sun, 14 Nov 2021 00:44:12 +0900 Subject: [PATCH 22/24] EUNA-319 --- WEEK5-B/EUNA-319/README.md | 39 ++++++++++++++++++++++++++++++++++++ WEEK5-B/EUNA-319/boj3972.cpp | 14 +++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 WEEK5-B/EUNA-319/README.md create mode 100644 WEEK5-B/EUNA-319/boj3972.cpp diff --git a/WEEK5-B/EUNA-319/README.md b/WEEK5-B/EUNA-319/README.md new file mode 100644 index 00000000..eaec2965 --- /dev/null +++ b/WEEK5-B/EUNA-319/README.md @@ -0,0 +1,39 @@ +## 분할 정복 공부 ## +

+ +### 탐색 ### +- 탐색: 다수의 레코드 집합에서 특정 키 값과 일치하는 레코드를 찾는 작업 +- 레코드는 객체의 속성에 해당하는 필드들의 집합으로 표현 +- 레코드를 식별하는데 사용되는 필드를 키 필드라고 부르고 키 필드를 통하여 레코드의 탐색이 이루어짐 +- 레코드의 집합을 리스트라고하는데 리스트의 파일 형식으로 디스크에 저장됨 +- 리스트의 레코드가 정렬되어 있는 경우 탐색 효율이 높아짐 +

+ +### DFS ### +- 인접 리스트의 시작 노드에서 출발하여 새로운 노드를 만날 때마다 해당 노드의 연결리스트로 분기하여 탐색하는 방법으로 함수 호출 구조와 유사 +- 특정 노드의 연결 리스트에 존재하는 인접 노드들을 모두 방문하면 해당 노드를 호출한 이전 노드의 연결 리스트로 돌아가서 미방문 노드를 계속 탐색 +- 시작 노드의 연결 리스트가 모두 방문되면 탐색을 종료 + + ```c++ + 정점(v)를 방문한 것으로 표시한다 + for(정점(v)에 인접한 모든 미방문 정점(u)에 대하여) + DFS(u) + } + ``` + - DFS 탐색을 통하여 그래프의 특정 노드를 포함하는 컴포넌트를 탐색할 수 있음 + - DFS 탐색은 그래프의 연결성을 확인하는데 사용됨 + - 연결 그래프가 아닌 경우 모든 노드가 탐색되지 않음 + - DFS 방법으로 방문할 때 사용된 간선만으로 이루어진 서브 그래프를 DSF 신장 트리 (DFS spanning tree)라고 함 + + ### BFS ### +- 큐를 이용하여 그래프를 탐색하는 방법 +- 트리의 레벨 순서 탐색과 유사 + ``` + 시작 정점 (1)을 방문한 것으로 표시하고 출력한 후 큐에 삽입 + 큐에서 이 정점을 다시 꺼내어 이 정점의 인접 리스트를 탐색하여 미방문 정점이 있으면 큐에 삽입 + 인접 리스트의 노드 탐색이 끝나면 큐에서 새로운 노드를 꺼내어 이 과정을 반복 + 큐에 더 이상 노드가 없으면 탐색을 종료 + + ``` + + diff --git a/WEEK5-B/EUNA-319/boj3972.cpp b/WEEK5-B/EUNA-319/boj3972.cpp new file mode 100644 index 00000000..2526888b --- /dev/null +++ b/WEEK5-B/EUNA-319/boj3972.cpp @@ -0,0 +1,14 @@ +#include +using namespace std; + +int main() { + int t, n, m,a,b; + cin>>t; + for(int i=0;i>n>>m; + for(int j=0;j>a>>b; + } + cout< Date: Sun, 14 Nov 2021 02:00:01 +0900 Subject: [PATCH 23/24] boj1260 --- WEEK5-B/EUNA-319/boj1260.cpp | 66 ++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 WEEK5-B/EUNA-319/boj1260.cpp diff --git a/WEEK5-B/EUNA-319/boj1260.cpp b/WEEK5-B/EUNA-319/boj1260.cpp new file mode 100644 index 00000000..de9bba85 --- /dev/null +++ b/WEEK5-B/EUNA-319/boj1260.cpp @@ -0,0 +1,66 @@ +#include +#include +using namespace std; +#define MAX 1001 + +int N, M, V; //정점개수, 간선개수, 시작정점 +int map[MAX][MAX]; //인접 행렬 그래프 +bool visited[MAX]; //정점 방문 여부 +queue q; + +void reset() { + for (int i = 1; i <= N; i++) { + visited[i] = 0; + } +} + +void DFS(int v) { + visited[v] = true; + cout << v << " "; + + for (int i = 1; i <= N; i++) { + if (map[v][i] == 1 && visited[i] == 0) { //현재 정점과 연결되어있고 방문되지 않았으면 + DFS(i); + } + } +} + +void BFS(int v) { + q.push(v); + visited[v] = true; + cout << v << " "; + + while (!q.empty()) { + v = q.front(); + q.pop(); + + for (int w = 1; w <= N; w++) { + if (map[v][w] == 1 && visited[w] == 0) { //현재 정점과 연결되어있고 방문되지 않았으면 + q.push(w); + visited[w] = true; + cout << w << " "; + } + } + } +} + +int main() { + cin >> N >> M >> V; + + for (int i = 0; i < M; i++) { + int a, b; + cin >> a >> b; + map[a][b] = 1; + map[b][a] = 1; + } + + reset(); + DFS(V); + + cout << '\n'; + + reset(); + BFS(V); + + return 0; +} From 8469a4f006bb0e5b54d4adb2ff092995f14359a0 Mon Sep 17 00:00:00 2001 From: fascinatioeuna <81363864+EUNA-319@users.noreply.github.com> Date: Sun, 14 Nov 2021 09:49:52 +0900 Subject: [PATCH 24/24] Update README.md --- WEEK5-B/EUNA-319/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WEEK5-B/EUNA-319/README.md b/WEEK5-B/EUNA-319/README.md index eaec2965..20ac1ec1 100644 --- a/WEEK5-B/EUNA-319/README.md +++ b/WEEK5-B/EUNA-319/README.md @@ -1,4 +1,4 @@ -## 분할 정복 공부 ## +## 그래프 (탐색, DFS, BFS) ##

### 탐색 ###