IT 프로그래밍/백준 55

[c++]백준 1076번 저항

문제 링크 : https://www.acmicpc.net/problem/1076코드#include #include #include using namespace std;int main(){ string color[10] = { "black", "brown", "red", "orange", "yellow", "green", "blue", "violet", "grey", "white" }; string n; int mem[3]; long long r = 0; for (int i = 0; i > n; for (int j = 0; j 문제풀이해당 식은 간단하게 문제를 따라서 풀면 나옵니다.* 결과값이 int 범위를 넘어가기 때문에 r을 long long으로 뒀습니다.* pow함수를 써야하기 때문에 #includ..

[C++] 백준 1094번 : 막대기

#include #include #include #define N 8using namespace std;int main(){ int x = 0; cin >> x; string binary = bitset(x).to_string(); int count = 0; for (int i = 0; i 문제 문제코드#include #include #include #define N 8using namespace std;int main(){ int x = 0; cin >> x; string binary = bitset(x).to_string(); int count = 0; for (int i = 0; i  문제풀이해당 문제는 Bitset을 알아야 풀 수 있는 문제입니다. 먼저 처음에 64cm를 가지고 있고 이후 계속 절..

C++ 백준 1075 나누기

문제`  풀이#include using namespace std;int main(){ int N, F; cin >> N >> F; N = (N / 100) * 100; for (int i = 0; i 먼저 풀이가 선뜻 떠오르진 않을 것입니다. 생각하는 과정이 조금 필요했던 문제라는 생각이 들어요. 브론즈 문제지만 조금은 시간이 필요했습니다. 해당 문제는 N의 마지막 두 자리 수를 더했을 때 F로 나누어 떨어지는 수를 찾는 문제인데요. 이것을 해결하기 위해선 N을 변형해주는 과정이 필요합니다. 마지막 두 자리 수를 00으로 만들어준 다음에 0부터 99까지 차례로 올라가면서 F로 나누어 떨어지는 값을 출력해주는 것을 목표로 합니다. 왜냐하면 최소값을 구해야 하기 때문에 for문을 통해 위쪽으로 올라가면서 처..

[C++] 백준 1316번 그룹 단어 체커

https://www.acmicpc.net/problem/1316 1316번: 그룹 단어 체커 그룹 단어란 단어에 존재하는 모든 문자에 대해서, 각 문자가 연속해서 나타나는 경우만을 말한다. 예를 들면, ccazzzzbb는 c, a, z, b가 모두 연속해서 나타나고, kin도 k, i, n이 연속해서 나타나기 때 www.acmicpc.net 코드 #include #include #include #include using namespace std; int main() { int n; cin >> n; string word; int count = 0; for (int i = 0; i > word; word.erase(unique(word.begin(), word.end()),..

[C++] 백준 2941번 크로아티아 알파벳

https://www.acmicpc.net/problem/2941 2941번: 크로아티아 알파벳 예전에는 운영체제에서 크로아티아 알파벳을 입력할 수가 없었다. 따라서, 다음과 같이 크로아티아 알파벳을 변경해서 입력했다. 크로아티아 알파벳 변경 č c= ć c- dž dz= đ d- lj lj nj nj š s= ž z= www.acmicpc.net 코드 #include #include #include #include using namespace std; int main() { vector croatian = {"c=", "c-", "dz=", "d-", "lj", "nj", "s=" ,"z=" }; string n; cin >> n; int idx; for (int i = 0; i < croatian.s..

[C++] 백준 1157번 단어 공부

https://www.acmicpc.net/problem/1157 1157번: 단어 공부 알파벳 대소문자로 된 단어가 주어지면, 이 단어에서 가장 많이 사용된 알파벳이 무엇인지 알아내는 프로그램을 작성하시오. 단, 대문자와 소문자를 구분하지 않는다. www.acmicpc.net 코드(C++) #include using namespace std; int main() { string n; cin >> n; int num[26] = { 0, }; for (int i = 0; i < n.length(); i++) { n[i] = toupper(n[i]); num[n[i] - 65] += 1; } int max = 0; int result; for (int i = 0; i < 26; i++) { if (num[i..

[C++] 백준 10988번 팰린드롬인지 확인하기

https://www.acmicpc.net/problem/10988 10988번: 팰린드롬인지 확인하기 첫째 줄에 단어가 주어진다. 단어의 길이는 1보다 크거나 같고, 100보다 작거나 같으며, 알파벳 소문자로만 이루어져 있다. www.acmicpc.net 풀이 #include #include using namespace std; int main() { string n; cin >> n; string m = n; char tmp; for (int i = 0; i < n.length() / 2; i++) { tmp = n[i]; n[i] = n[n.length() - 1 - i]; n[n.length() - 1 - i] = tmp; } if (m == n) { cout