From 652101cbfbcb90ca067316e8a4e7bf7e42d11856 Mon Sep 17 00:00:00 2001 From: sari-harin Date: Wed, 6 Sep 2023 18:32:12 +0900 Subject: [PATCH 1/7] =?UTF-8?q?[=20=EC=A0=95=EC=88=98=EB=A1=A0=20]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../1735.cpp" | 35 +++++++++++ .../2840.cpp" | 59 +++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 "03_\354\240\225\354\210\230\353\241\240/1735.cpp" create mode 100644 "03_\354\240\225\354\210\230\353\241\240/2840.cpp" diff --git "a/03_\354\240\225\354\210\230\353\241\240/1735.cpp" "b/03_\354\240\225\354\210\230\353\241\240/1735.cpp" new file mode 100644 index 0000000..c6a8ada --- /dev/null +++ "b/03_\354\240\225\354\210\230\353\241\240/1735.cpp" @@ -0,0 +1,35 @@ + +#include + +using namespace std; + +int getGcd(int a, int b) { + int tmp; + while (b != 0) { + tmp = a % b; + a = b; + b = tmp; + } + return a; +} + + +int main() +{ + int a1, a2, b1, b2, c1, c2; + + cin >> a1 >> a2; + cin >> b1 >> b2; + + c1 = a1*b2 + a2*b1; + c2 = a2*b2; + + int gcd_c = getGcd(c1,c2); + + c1/=gcd_c; + c2/=gcd_c; + + cout << c1 << ' ' << c2; + + return 0; +} \ No newline at end of file diff --git "a/03_\354\240\225\354\210\230\353\241\240/2840.cpp" "b/03_\354\240\225\354\210\230\353\241\240/2840.cpp" new file mode 100644 index 0000000..1924af6 --- /dev/null +++ "b/03_\354\240\225\354\210\230\353\241\240/2840.cpp" @@ -0,0 +1,59 @@ +#include +#include + +using namespace std; + +int main() +{ + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + + int n, k, pt; + + cin >> n >> k; + + vector arr(n,'?'); + + for(int i=0;i> turns >> c; + + if(i==0){ + pt=i; + arr[i]=c; + continue; + } + + pt=(pt+turns)%n; + if(arr[pt]!='?' && arr[pt]!=c){ + cout << "!"; + return 0; + } + else{ + arr[pt]=c; + } + + } + + for(int i=0;i Date: Thu, 7 Sep 2023 22:07:53 +0900 Subject: [PATCH 2/7] =?UTF-8?q?[=20=EC=A0=95=EC=88=98=EB=A1=A0=20]=209?= =?UTF-8?q?=EC=9B=94=207=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../6588.cpp" | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 "03_\354\240\225\354\210\230\353\241\240/6588.cpp" diff --git "a/03_\354\240\225\354\210\230\353\241\240/6588.cpp" "b/03_\354\240\225\354\210\230\353\241\240/6588.cpp" new file mode 100644 index 0000000..ad3036d --- /dev/null +++ "b/03_\354\240\225\354\210\230\353\241\240/6588.cpp" @@ -0,0 +1,55 @@ +#include +#include +#include + +using namespace std; + +vector getPrimes(int n) { //소수 여부를 반환 + vector is_prime(n + 1, true); //소수 여부를 저장할 벡터 + is_prime[0] = is_prime[1] = false; //0과 1은 소수가 아니므로 false 저장 + for (int i = 2; i * i <= n; i++) { //n의 제곱근보다 낮은 범위에서 탐색 + if (!is_prime[i]) { //소수가 아닐 시 + continue; //처음으로 되돌아감 + } + for (int j = i * i; j <= n; j += i) { //배수는 제외 + is_prime[j] = false; //배수는 제외 + } + } + return is_prime; //결과 리턴(소수 여부가 저장된 벡터) +} + + +int goldbach(int n, vector &is_prime) { //n=a+b인 a 리턴 + for (int a = 3; a <= n / 2; a+= 2) { //3부터 홀수 중 탐색(2보다 큰 짝수 소수는 존재하지 않기 때문) + if (is_prime[a] && is_prime[n - a]) { //n=a+b에서 a와 b가 모두 소수라면 + return a; //n=a+b인 a 리턴 + } + } + return 0; //해당하는 a와 b가 없으면 0 리턴 +} + +int main() { //메인함수 + vector arr; //배열 선언 + int input; //입력값 받을 변수 + while(1) { //무한반복 + cin >> input; //입력 받기 + if (input == 0) { //사용자가 0을 입력하면 + break; //루프 끝 + } + arr.push_back(input); //벡터 끝에 입력값 넣기 + } + + int max_num = *max_element(arr.begin(), arr.end()); //배열의 처음부터 끝까지 가장 큰 수를 저장(값 참조) + vector is_prime = getPrimes(max_num); //소수 얻기 + + for (int i = 0; i < arr.size(); i++) { //배열 내에서 반복 + int a = goldbach(arr[i], is_prime); //n=a+b인 a 리턴 + + if (a != 0) { // n=a+b인 a, b가 존재하는 경우 + cout << arr[i] << " = " << a << " + " << arr[i] - a << "\n"; //결과 출력 + } else { //존재하지 않는 경우 + cout << "Goldbach's conjecture is wrong.\n"; //결과 출력 + } + } + return 0; //종료 +} \ No newline at end of file From daf12131bf2260480924db026d1f16af1566a11d Mon Sep 17 00:00:00 2001 From: sari-harin Date: Wed, 13 Sep 2023 15:44:50 +0900 Subject: [PATCH 3/7] =?UTF-8?q?[=20=EB=B8=8C=EB=A3=A8=ED=8A=B8=ED=8F=AC?= =?UTF-8?q?=EC=8A=A4=20]=209=EC=9B=94=2013=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../1063.cpp" | 71 +++++++++++++++++++ .../11723.cpp" | 48 +++++++++++++ .../1436.cpp" | 32 +++++++++ 3 files changed, 151 insertions(+) create mode 100644 "04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/1063.cpp" create mode 100644 "04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/11723.cpp" create mode 100644 "04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/1436.cpp" diff --git "a/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/1063.cpp" "b/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/1063.cpp" new file mode 100644 index 0000000..8fa7b70 --- /dev/null +++ "b/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/1063.cpp" @@ -0,0 +1,71 @@ +#include +#include + +using namespace std; + +int main() +{ + string king, rock, dir_str; + int num, kingX, kingY, rockX, rockY, dir; + + cin >> king >> rock >> num; + + kingX='8'-king[1]; + kingY=king[0]-'A'; + rockX='8'-rock[1]; + rockY=rock[0]-'A'; + + int chessX[8]={0, 0, 1, -1, -1, -1, 1, 1}; + int chessY[8]={1, -1, 0, 0, 1, -1, 1, -1}; + + for(int i=0;i> dir_str; + if(dir_str=="R"){ + dir=0; + } + else if(dir_str=="L"){ + dir=1; + } + else if(dir_str=="B"){ + dir=2; + } + else if(dir_str=="T"){ + dir=3; + } + else if(dir_str=="RT"){ + dir=4; + } + else if(dir_str=="LT"){ + dir=5; + } + else if(dir_str=="RB"){ + dir=6; + } + else if(dir_str=="LB"){ + dir=7; + } + + int kx=kingX+chessX[dir]; + int ky=kingY+chessY[dir]; + + if (kx<0 || kx>7 || ky<0 || ky>7){ + continue; + } + if(kx==rockX && ky==rockY){ + int rx=rockX+chessX[dir]; + int ry=rockY+chessY[dir]; + if(rx<0 || rx>7 || ry<0 || ry>7){ + continue; + } + rockX=rx; + rockY=ry; + } + kingX=kx; + kingY=ky; + } + + cout << (char)(kingY+'A') << 8-kingX << '\n'; + cout << (char)(rockY+'A') << 8-rockX << '\n'; + + return 0; +} \ No newline at end of file diff --git "a/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/11723.cpp" "b/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/11723.cpp" new file mode 100644 index 0000000..f91d05f --- /dev/null +++ "b/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/11723.cpp" @@ -0,0 +1,48 @@ +#include + +using namespace std; + +int main(){ + + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + + int n, S=0, cmd_num; + string cmd=""; + + cin >> n; + + for(int i=0;i> cmd; + if(cmd=="add"){ + cin>>cmd_num; + S|=(1<> cmd_num; + S&= ~(1<>cmd_num; + if(S&(1<>cmd_num; + S^=(1< + +using namespace std; + +int main(){ + + int n, n_temp, count=1, num=666; + + cin >> n; + + while(count!=n){ + if(n==1){ + break; + } + + num++; + n_temp=num; + + while(n_temp!=0){ + if(n_temp%1000==666){ + count++; + break; + } + else{ + n_temp/=10; + } + } + } + + cout << num; + return 0; +} \ No newline at end of file From 56b322059e48c47753ddbaee2ea7dda061964fdf Mon Sep 17 00:00:00 2001 From: sari-harin Date: Tue, 19 Sep 2023 22:34:29 +0900 Subject: [PATCH 4/7] =?UTF-8?q?[=20=EC=9A=B0=EC=84=A0=EC=88=9C=EC=9C=84=20?= =?UTF-8?q?=ED=81=90=20]=209=EC=9B=94=2019=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../14235.cpp" | 33 +++++++++++++++++++ .../2075.cpp" | 29 ++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 "05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/14235.cpp" create mode 100644 "05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2075.cpp" diff --git "a/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/14235.cpp" "b/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/14235.cpp" new file mode 100644 index 0000000..c11e09b --- /dev/null +++ "b/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/14235.cpp" @@ -0,0 +1,33 @@ +#include +#include + +using namespace std; + +int main() +{ + int n, a, gift; + priority_queue pq; + + cin >> n; + + while(n--){ + cin >> a; + if(a==0){ + if(pq.empty()){ + cout << -1 << '\n'; + } + else{ + cout << pq.top() << '\n'; + pq.pop(); + } + } + else{ + while(a--){ + cin >> gift; + pq.push(gift); + } + } + } + + return 0; +} \ No newline at end of file diff --git "a/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2075.cpp" "b/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2075.cpp" new file mode 100644 index 0000000..b7ac188 --- /dev/null +++ "b/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2075.cpp" @@ -0,0 +1,29 @@ +#include +#include + +using namespace std; + +int main() +{ + + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + + int n, num; + priority_queue, greater> pq; + + cin >> n; + + for(int i=0;i> num; + pq.push(num); + if(pq.size() > n){ + pq.pop(); + } + } + + cout << pq.top(); + + return 0; +} \ No newline at end of file From 80d27a9cba939513f76e6e8d8420f2c34f74fc9f Mon Sep 17 00:00:00 2001 From: sari-harin <1303sari@gmail.com> Date: Thu, 21 Sep 2023 21:38:09 +0900 Subject: [PATCH 5/7] =?UTF-8?q?[=20=EC=9A=B0=EC=84=A0=EC=88=9C=EC=9C=84=20?= =?UTF-8?q?=ED=81=90=20]=209=EC=9B=94=2021=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2607.cpp" | 49 +++++++++++++++++++ Altu-Bitu-HarinLee | 1 + 2 files changed, 50 insertions(+) create mode 100644 "05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2607.cpp" create mode 160000 Altu-Bitu-HarinLee diff --git "a/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2607.cpp" "b/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2607.cpp" new file mode 100644 index 0000000..991d314 --- /dev/null +++ "b/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2607.cpp" @@ -0,0 +1,49 @@ +#include +#include + +using namespace std; + +const int NUM_CHARS = 26; //상수 선언 + +void countFreq(string word, vector &freq) { //각 알파벡의 개수를 센다 + for (int i = 0; i < word.length(); i++) { //받은 단어의 알파벳을 모두 돌며 + freq[word[i] - 'A']++; //받은 벡터에 각 알파벳의 개수를 센다 + } +} + +int countDiff(string word, vector original_freq) { //차이를 센다 + vector freq(NUM_CHARS, 0); //빈도(개수)를 세는 벡터 + int diff = 0; //원본 단어와의 차이를 저장할 변수 + + countFreq(word, freq); // 각 알파벳의 개수 세기 + + for (int i = 0; i < NUM_CHARS; i++) { //알파벳 개수동안 + diff += abs(original_freq[i] - freq[i]); //원본 단어와 다른 알파벳의 개수를 변수에 넣기 + } + return diff; //diff를 반환 +} + +int main() { //메인 + int N, ans=0; //입력받을 변수와 결과를 담을 변수 + string original; //원본 문자열 + + cin >> N; //입력 받기 + cin >> original; //원본 문자열 입력 받기 + vector original_freq(NUM_CHARS, 0); //기존 문자열에서 알파벳의 개수를 저장할 벡터 + + countFreq(original, original_freq); //기존 문자열의 알파벳의 개수 계산 + + for (int i = 1; i < N; i++) { //입력받은 n만큼 반복 + string word; //비교할 문자열 + cin >> word; //비교할 문자열 입력받기 + + int diff = countDiff(word, original_freq); //기존 문자열과의 차이 저장 + + if (diff == 0 || diff == 1 || diff == 2 && original.length() == word.length()) { //조건에 맞는 비슷한 단어라면 + ans++; //개수 세기 + } + } + + cout << ans; //결과 출력 + return 0; //종료 +} \ No newline at end of file diff --git a/Altu-Bitu-HarinLee b/Altu-Bitu-HarinLee new file mode 160000 index 0000000..f130cd7 --- /dev/null +++ b/Altu-Bitu-HarinLee @@ -0,0 +1 @@ +Subproject commit f130cd7f4ff148f6934d363c983778c53bb07e90 From af505ba3343a4d0eaf59ba41e1bdc99ec032c672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=ED=95=98=EB=A6=B0?= <124681672+sari-harin@users.noreply.github.com> Date: Thu, 21 Sep 2023 21:40:23 +0900 Subject: [PATCH 6/7] =?UTF-8?q?Delete=2004=5F=EB=B8=8C=EB=A3=A8=ED=8A=B8?= =?UTF-8?q?=ED=8F=AC=EC=8A=A4=20directory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../1063.cpp" | 71 ------------------- .../11723.cpp" | 48 ------------- .../1436.cpp" | 32 --------- 3 files changed, 151 deletions(-) delete mode 100644 "04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/1063.cpp" delete mode 100644 "04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/11723.cpp" delete mode 100644 "04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/1436.cpp" diff --git "a/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/1063.cpp" "b/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/1063.cpp" deleted file mode 100644 index 8fa7b70..0000000 --- "a/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/1063.cpp" +++ /dev/null @@ -1,71 +0,0 @@ -#include -#include - -using namespace std; - -int main() -{ - string king, rock, dir_str; - int num, kingX, kingY, rockX, rockY, dir; - - cin >> king >> rock >> num; - - kingX='8'-king[1]; - kingY=king[0]-'A'; - rockX='8'-rock[1]; - rockY=rock[0]-'A'; - - int chessX[8]={0, 0, 1, -1, -1, -1, 1, 1}; - int chessY[8]={1, -1, 0, 0, 1, -1, 1, -1}; - - for(int i=0;i> dir_str; - if(dir_str=="R"){ - dir=0; - } - else if(dir_str=="L"){ - dir=1; - } - else if(dir_str=="B"){ - dir=2; - } - else if(dir_str=="T"){ - dir=3; - } - else if(dir_str=="RT"){ - dir=4; - } - else if(dir_str=="LT"){ - dir=5; - } - else if(dir_str=="RB"){ - dir=6; - } - else if(dir_str=="LB"){ - dir=7; - } - - int kx=kingX+chessX[dir]; - int ky=kingY+chessY[dir]; - - if (kx<0 || kx>7 || ky<0 || ky>7){ - continue; - } - if(kx==rockX && ky==rockY){ - int rx=rockX+chessX[dir]; - int ry=rockY+chessY[dir]; - if(rx<0 || rx>7 || ry<0 || ry>7){ - continue; - } - rockX=rx; - rockY=ry; - } - kingX=kx; - kingY=ky; - } - - cout << (char)(kingY+'A') << 8-kingX << '\n'; - cout << (char)(rockY+'A') << 8-rockX << '\n'; - - return 0; -} \ No newline at end of file diff --git "a/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/11723.cpp" "b/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/11723.cpp" deleted file mode 100644 index f91d05f..0000000 --- "a/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/11723.cpp" +++ /dev/null @@ -1,48 +0,0 @@ -#include - -using namespace std; - -int main(){ - - ios_base::sync_with_stdio(false); - cin.tie(NULL); - cout.tie(NULL); - - int n, S=0, cmd_num; - string cmd=""; - - cin >> n; - - for(int i=0;i> cmd; - if(cmd=="add"){ - cin>>cmd_num; - S|=(1<> cmd_num; - S&= ~(1<>cmd_num; - if(S&(1<>cmd_num; - S^=(1< - -using namespace std; - -int main(){ - - int n, n_temp, count=1, num=666; - - cin >> n; - - while(count!=n){ - if(n==1){ - break; - } - - num++; - n_temp=num; - - while(n_temp!=0){ - if(n_temp%1000==666){ - count++; - break; - } - else{ - n_temp/=10; - } - } - } - - cout << num; - return 0; -} \ No newline at end of file From 7997acad6f294448c639826588059ee3cf030b8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=ED=95=98=EB=A6=B0?= <124681672+sari-harin@users.noreply.github.com> Date: Thu, 21 Sep 2023 21:40:35 +0900 Subject: [PATCH 7/7] =?UTF-8?q?Delete=2003=5F=EC=A0=95=EC=88=98=EB=A1=A0?= =?UTF-8?q?=20directory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../1735.cpp" | 35 ----------- .../2840.cpp" | 59 ------------------- .../6588.cpp" | 55 ----------------- 3 files changed, 149 deletions(-) delete mode 100644 "03_\354\240\225\354\210\230\353\241\240/1735.cpp" delete mode 100644 "03_\354\240\225\354\210\230\353\241\240/2840.cpp" delete mode 100644 "03_\354\240\225\354\210\230\353\241\240/6588.cpp" diff --git "a/03_\354\240\225\354\210\230\353\241\240/1735.cpp" "b/03_\354\240\225\354\210\230\353\241\240/1735.cpp" deleted file mode 100644 index c6a8ada..0000000 --- "a/03_\354\240\225\354\210\230\353\241\240/1735.cpp" +++ /dev/null @@ -1,35 +0,0 @@ - -#include - -using namespace std; - -int getGcd(int a, int b) { - int tmp; - while (b != 0) { - tmp = a % b; - a = b; - b = tmp; - } - return a; -} - - -int main() -{ - int a1, a2, b1, b2, c1, c2; - - cin >> a1 >> a2; - cin >> b1 >> b2; - - c1 = a1*b2 + a2*b1; - c2 = a2*b2; - - int gcd_c = getGcd(c1,c2); - - c1/=gcd_c; - c2/=gcd_c; - - cout << c1 << ' ' << c2; - - return 0; -} \ No newline at end of file diff --git "a/03_\354\240\225\354\210\230\353\241\240/2840.cpp" "b/03_\354\240\225\354\210\230\353\241\240/2840.cpp" deleted file mode 100644 index 1924af6..0000000 --- "a/03_\354\240\225\354\210\230\353\241\240/2840.cpp" +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include - -using namespace std; - -int main() -{ - ios_base::sync_with_stdio(false); - cin.tie(NULL); - cout.tie(NULL); - - int n, k, pt; - - cin >> n >> k; - - vector arr(n,'?'); - - for(int i=0;i> turns >> c; - - if(i==0){ - pt=i; - arr[i]=c; - continue; - } - - pt=(pt+turns)%n; - if(arr[pt]!='?' && arr[pt]!=c){ - cout << "!"; - return 0; - } - else{ - arr[pt]=c; - } - - } - - for(int i=0;i -#include -#include - -using namespace std; - -vector getPrimes(int n) { //소수 여부를 반환 - vector is_prime(n + 1, true); //소수 여부를 저장할 벡터 - is_prime[0] = is_prime[1] = false; //0과 1은 소수가 아니므로 false 저장 - for (int i = 2; i * i <= n; i++) { //n의 제곱근보다 낮은 범위에서 탐색 - if (!is_prime[i]) { //소수가 아닐 시 - continue; //처음으로 되돌아감 - } - for (int j = i * i; j <= n; j += i) { //배수는 제외 - is_prime[j] = false; //배수는 제외 - } - } - return is_prime; //결과 리턴(소수 여부가 저장된 벡터) -} - - -int goldbach(int n, vector &is_prime) { //n=a+b인 a 리턴 - for (int a = 3; a <= n / 2; a+= 2) { //3부터 홀수 중 탐색(2보다 큰 짝수 소수는 존재하지 않기 때문) - if (is_prime[a] && is_prime[n - a]) { //n=a+b에서 a와 b가 모두 소수라면 - return a; //n=a+b인 a 리턴 - } - } - return 0; //해당하는 a와 b가 없으면 0 리턴 -} - -int main() { //메인함수 - vector arr; //배열 선언 - int input; //입력값 받을 변수 - while(1) { //무한반복 - cin >> input; //입력 받기 - if (input == 0) { //사용자가 0을 입력하면 - break; //루프 끝 - } - arr.push_back(input); //벡터 끝에 입력값 넣기 - } - - int max_num = *max_element(arr.begin(), arr.end()); //배열의 처음부터 끝까지 가장 큰 수를 저장(값 참조) - vector is_prime = getPrimes(max_num); //소수 얻기 - - for (int i = 0; i < arr.size(); i++) { //배열 내에서 반복 - int a = goldbach(arr[i], is_prime); //n=a+b인 a 리턴 - - if (a != 0) { // n=a+b인 a, b가 존재하는 경우 - cout << arr[i] << " = " << a << " + " << arr[i] - a << "\n"; //결과 출력 - } else { //존재하지 않는 경우 - cout << "Goldbach's conjecture is wrong.\n"; //결과 출력 - } - } - return 0; //종료 -} \ No newline at end of file