diff --git a/10757_AB b/10757_AB new file mode 100644 index 0000000..a27084a --- /dev/null +++ b/10757_AB @@ -0,0 +1,54 @@ +#include +#include + +using namespace std; + +int main() +{ + string a, b; + vector ans; + cin >> a >> b; + + if (a.length()>b.length()) + { + while(a.length() != b.length()) + { + b.insert(0, "0"); + } + } + else + { + while(a.length() != b.length()) + { + a.insert(0, "0"); + } + } + + bool isRound = 0; + int sum; + for (int i = a.length() - 1; i>=0; --i) + { + sum = (a[i] - '0' + b[i] - '0'); + if (isRound) + { + ++sum; + } + if (sum >= 10) + { + isRound = 1; + } + else + { + isRound = 0; + } + ans.push_back(sum % 10); + } + if(isRound) ans.push_back(1); + + for (int i = ans.size() - 1; i>=0; --i) + { + cout << ans[i]; + } + + return 0; +} \ No newline at end of file diff --git a/1158_ b/1158_ new file mode 100644 index 0000000..7095ffc --- /dev/null +++ b/1158_ @@ -0,0 +1,35 @@ +#include +#include +#include + +using namespace std; + +int main() +{ + int n, k; + + vector v; + queue q; + + cin >> n >> k; + + for (int i = 1; i <= n; i++){ + q.push(i); + } + while(!q.empty()){ + for (int i = 0; i < k-1; i++){ + q.push(q.front()); + q.pop(); + } + v.push_back(q.front()); + q.pop(); + } + + cout << "<"; + for (int i = 0; i < n-1; i++){ + cout << v[i] << ","; + } + cout << v[n-1] << ">"; + + return 0; +} \ No newline at end of file diff --git a/1431_SERIAL.cpp b/1431_SERIAL.cpp new file mode 100644 index 0000000..4bb6334 --- /dev/null +++ b/1431_SERIAL.cpp @@ -0,0 +1,52 @@ +#include +#include +#include + +using namespace std; + +int n; +string a[1000]; + +int integer_sum(string a){ + int length = a.length(); + int sum =0; + for(int i = 0; i =0){ + sum += a[i] - '0'; + } + } + return sum; +} + +bool compare (string a, string b){ + if(a.length()b.length()){ + return 0; + } + else { + int sum_a = integer_sum(a); + int sum_b = integer_sum(b); + + if (sum_a < sum_b){ + return 1; + } + else if (sum_a > sum_b) { + return 0; + } + else { + return a < b; + } + } +} +int main(){ + cin >> n; + for (int i = 0; i < n; i++){ + cin >> a[i]; + } + sort (a, a+n, compare); + for (int i = 0; i < n; i++){ + cout << a[i] << ' ' < +#include +#include + +using namespace std; + +int n, m, cnt = 0; +set s; + +int main() +{ + ios_base::sync_with_stdio(0); + cin.tie(0); + + cin >> n >> m; + for (int i = 0; i < n; i++){ + string tmp; + cin >> tmp; + s.insert(tmp); + } + for (int i = 0; i > tmp; + if (s.find(tmp) != s.end()) cnt++; + } + cout < +#include + +using namespace std; + +int main(){ + int w, basic, t, day; + int d_input, d_output; + + cin >> w >> basic >> t; + cin >> day >> d_input >> d_output; + + int w1 = w; + int w2 = w; + + int basic2 = basic; + + for(int i=0; it) + basic2 += floor((d_input - (basic2+d_output))/2.0); + } + if (21 <= 0) + cout << "Danger Diet\n"; + else + cout << w1 << " " << basic << "\n"; + + if (w2 <= 0 || basic2 <= 0) + cout << "Danger Diet\n"; + else{ + cout << w2 << " " << basic2 << " "; + if (basic - basic2 > 0) + cout << "YOYO"; + else + cout << "NO"; + } +} \ No newline at end of file diff --git a/4949_yesno b/4949_yesno new file mode 100644 index 0000000..43234d2 --- /dev/null +++ b/4949_yesno @@ -0,0 +1,46 @@ +#include +#include +#include + +using namespace std; + +int main() +{ + while(1) { + stack s; + string str; + getline(cin, str); + + if (str == ".") + return 0; + + bool flag = true; + for (int i = 0; i < str.length(); i++) { + if (str[i] == '(' || str[i] == '[') + s.push(str[i]); + else if (str[i]== ')') { + if (!s.empty()&&s.top()=='(') + s.pop(); + else { + flag = false; + break; + } + } + else if (str[i]==']'){ + if(!s.empty()&& s.top()=='[') + s.pop(); + else + { + flag = false; + break; + } + } + } + if (flag && s.empty()) + cout << "yes" << endl; + else + cout << "no" << endl; + cout << '\n'; + } + return 0; +} \ No newline at end of file diff --git a/BOJ_1001.cpp b/BOJ_1001.cpp new file mode 100644 index 0000000..ef11ca5 --- /dev/null +++ b/BOJ_1001.cpp @@ -0,0 +1,11 @@ +#include + +using namespace std; + +int main(){ + string str; + cin >> str; + + cout << "알튜비튜 7기 화이팅!" + cout << "중도하차 안돼요!" +} \ No newline at end of file