From 5fcda7815aa22042f6845a505af41ba61efcf8e0 Mon Sep 17 00:00:00 2001 From: sohyundoh Date: Thu, 24 Mar 2022 19:05:31 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B8=8C=EB=A3=A8=ED=8A=B8=ED=8F=AC=EC=8A=A4?= =?UTF-8?q?=20second=20touch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/PULL_REQUEST_TEMPLATE.md | 6 +- .../10757.cpp" | 134 +++++++----------- .../2503.cpp" | 48 +++++++ 3 files changed, 103 insertions(+), 85 deletions(-) create mode 100644 "[\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244] 3\354\233\224 24\354\235\274/2503.cpp" diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index e18d5de..0ee1315 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,11 +1,11 @@ ### 내용 & 질문 -> 10757 코드 정리를 못하겠고 런타임 에러가 나는 이유를 모르겠습니다.. +> 10757 코드의 어느부분이 틀렸는지 모르겠습니다. 2503번 tc 체크하는 코드를 다시 짤 계획입니다. ### <기존 제출> -> 2776, 11478, 20291 +> 10757,2503 ### <추가 제출> -> X \ No newline at end of file +> \ No newline at end of file diff --git "a/[\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244] 3\354\233\224 24\354\235\274/10757.cpp" "b/[\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244] 3\354\233\224 24\354\235\274/10757.cpp" index d4b51f5..2a48f18 100644 --- "a/[\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244] 3\354\233\224 24\354\235\274/10757.cpp" +++ "b/[\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244] 3\354\233\224 24\354\235\274/10757.cpp" @@ -1,100 +1,70 @@ #include +#include using namespace std; -//ϴ ũ Է¹ ȵȴ. ڿ Է¹޾ƾѴ. +//ڰ ʹ Ŀ ǥϸ ÷ο찡 Ͼ . ׷ ڿ ޾Ƽ ڸ ֱ +//ڸ ö ex)13ڸ => 14ڸ reverseԼ ؼ Ųٷ ϱ... int main() { string a, b; - string result = 0; cin >> a >> b; - int a_size = a.length(); - int b_size = b.length(); - int r[10000] = { 0, }; //string ڸ ٰ ö󰡰 Ǵ ϱ + int a_size = a.length(), b_size = b.length(); + reverse(a.begin(), a.end()); + reverse(b.begin(), b.end()); + int round; + int result[10000]; if (a_size > b_size) { - for (int i = 0; i < a_size; i++) { - if (i > b_size) { // ̰ ٸ - if (i >= 1) { - if ((int)(a[i]) + r[i - 1] >= 10) { - r[i] = ((int)(a[i]) + r[i - 1]) / 10; // ö󰡰 Ǵ ϱ - result[i] = ((int)(a[i]) + r[i - 1]) % 10; - } - else { - result[i] = ((int)(a[i]) + r[i - 1]); - } - } - else { - if ((int)(a[i] + b[i]) >= 10) { - r[i] = ((int)(a[i] + b[i])) / 10; // ö󰡰 Ǵ ϱ - result[i] = ((int)(a[i] + b[i])) % 10; - } - else { - result[i] = ((int)(a[i] + b[i])); - } - } + result[0] = ((int)a[0] + (int)b[0]) % 10; + round = ((int)a[0] + (int)b[0]) / 10; + for (int i = 1; i < a_size; i++) { + if (i <= b_size) { + result[i] = ((int)a[i] + (int)b[i] + round) % 10; + round = ((int)a[i] + (int)b[i] + round) / 10; } else { - if (i >= 1) { - if ((int)(a[i] + b[i]) + r[i - 1] >= 10) { - r[i] = ((int)(a[i] + b[i]) + r[i - 1]) / 10; // ö󰡰 Ǵ ϱ - result[i] = ((int)(a[i] + b[i]) + r[i - 1]) % 10; - } - else { - result[i] = ((int)(a[i] + b[i]) + r[i - 1]); - } - } - else { - if ((int)(a[i] + b[i]) >= 10) { - r[i] = ((int)(a[i] + b[i])) / 10; // ö󰡰 Ǵ ϱ - result[i] = ((int)(a[i] + b[i])) % 10; - } - else { - result[i] = ((int)(a[i] + b[i])); - } - } + result[i] = ((int)a[i] + round) % 10; + round = ((int)a[i] + round) / 10; } } + if (result[a_size] > 0) { + reverse(result, result + a_size); + for (int i = 0; i < (a_size + 1); i++) { + cout << result[i]; + } + } + else { + reverse(result, result + a_size - 1); + for (int i = 0; i < (a_size); i++) { + cout << result[i]; + } + } + } else { - for (int i = 0; i < b_size; i++) { - if (i > a_size) { - if (i >= 1) { - if ((int)(b[i]) + r[i - 1] >= 10) { - r[i] = ((int)(b[i]) + r[i - 1]) / 10; // ö󰡰 Ǵ ϱ - result[i] = ((int)(b[i]) + r[i - 1]) % 10; - } - else { - result[i] = ((int)(b[i]) + r[i - 1]); - } - } - else { - if ((int)(b[i]) >= 10) { - r[i] = ((int)(b[i])) / 10; // ö󰡰 Ǵ ϱ - result[i] = ((int)(b[i])) % 10; - } - else { - result[i] = ((int)(b[i])); - } - } + result[0] = ((int)a[0] + (int)b[0]) % 10; + round = ((int)a[0] + (int)b[0]) / 10; + for (int i = 1; i < b_size; i++) { + if (i <= a_size) { + result[i] = ((int)a[i] + (int)b[i] + round) % 10; + round = ((int)a[i] + (int)b[i] + round) / 10; } else { - if (i >= 1) { - if ((int)(a[i] + b[i]) + r[i - 1] >= 10) { - r[i] = ((int)(a[i] + b[i]) + r[i - 1]) / 10; // ö󰡰 Ǵ ϱ - result[i] = ((int)(a[i] + b[i]) + r[i - 1]) % 10; - } - else { - result[i] = ((int)(a[i] + b[i]) + r[i - 1]); - } - } - else { - if ((int)(a[i] + b[i]) >= 10) { - r[i] = ((int)(a[i] + b[i])) / 10; // ö󰡰 Ǵ ϱ - result[i] = ((int)(a[i] + b[i])) % 10; - } - else { - result[i] = ((int)(a[i] + b[i])); - } - } + result[i] = ((int)b[i] + round) % 10; + round = ((int)b[i] + round) / 10; + }; + } + if (result[b_size] > 0) { + reverse(result, result + b_size); + for (int i = 0; i < (b_size + 1); i++) { + cout << result[i]; + } + } + else { + reverse(result, result + b_size - 1); + for (int i = 0; i < (b_size); i++) { + cout << result[i]; } } } - cout << result; + + //result ũⰡ 10000̱ .. ״ ϸ ȵ... + } \ No newline at end of file diff --git "a/[\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244] 3\354\233\224 24\354\235\274/2503.cpp" "b/[\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244] 3\354\233\224 24\354\235\274/2503.cpp" new file mode 100644 index 0000000..b7f3d42 --- /dev/null +++ "b/[\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244] 3\354\233\224 24\354\235\274/2503.cpp" @@ -0,0 +1,48 @@ +#include +#include +using namespace std; +int main() { + int N; + cin >> N; + int tc[100]; + int strike[100]; + int ball[100]; + int cnt = 0; + int h, t, o, th, tt, to; + bool flag[900] = { false, };//ڿ ´ Ȯ 迭 + for (int i = 0; i < N; i++) { + int test_strike = 0, test_ball = 0; + cin >> tc[i] >> strike[i] >> ball[i]; + h = tc[i] / 100; + t = (tc[i] % 100) / 10; + o = tc[i] - 100 * h - 10 * t; + for (int j = 0; j < 900; j++) { + th = (j + 100) / 100; + tt = ((j + 100) % 100) / 10; + to = (j + 100) % 10; + if (th == tt || th == to || tt == to || tt == 0 || to == 0) { //0 ְų ڸ + flag[j] = false; + continue; + } + if (th == h) test_strike++; // Ȯϴ ǵ... ̺κ ߸ + else if (th == t) test_ball++; + else if (th == o) test_ball++; + if (tt == t) test_strike++; + else if (tt == h) test_ball++; + else if (tt == o) test_ball++; + if (to == o) test_strike++; + else if (to == h) test_ball++; + else if (to == t) test_ball++; + if (test_ball == ball[i] && test_strike == strike[i]) { // Ȯ ball strike Է¹ true ȯ... + flag[j] = true; + } + else { + flag[j] = false; + } + } + } + for (int i = 0; i < 900; i++) { + if (flag[i]) cnt++; + } + cout << cnt; +} \ No newline at end of file