본문 바로가기

전체 글

백준 2979번 - 트럭 주차 더보기
백준 10808번 알파벳 개수 #include #include #include using namespace std;int main() { string s; cin >> s; vector arr(26, 0); for(char c:s) { arr[c-'a'] += 1; } for(int i=0; i 더보기
백준 2309번 일곱 난쟁이 (이미지 백업되어있음) #include #include #include #include using namespace std;int main() { vector people; int a; while(people.size() > a; people.push_back(a); } sort(people.begin(), people.end()); do { int sum = 0; for (int i = 0; i 더보기
프로그래머스 - 공원 산책 #include #include using namespace std;vector solution(vector park, vector routes) { vector start = {0, 0}; int h = park.size(); int w = park[0].size(); for (int i = 0; i = h || x = w) { canMove = false; break; } if (park[y][x] == 'X') { canMove = false; break; } } if (canMove) {.. 더보기
프로그래머스 - 두 정수 사이의 합 #include #include using namespace std;long long solution(int a, int b) { long long answer = 0; if(a내 코드. 그냥 나눠서 풀었다.#include #include using namespace std;long long solution(int A, int B) { long long answer = 0; int a = A 삼항연산자..!! 더보기
프로그래머스 - 정수 제곱근 판별 #include #include #include using namespace std;long long power10(int cnt) { long long result = 1; for (int i = 0; i n) { break; } } return -1;}long long solution(long long n) { string s = to_string(n); int length = s.size(); return sqr(length, n);}큰 숫자에 쫄아서 자릿수를 계산해서 범위를 줄인뒤 계산하게 했지만.... 그냥 풀자..#include #include #include using namespace std;long long solut.. 더보기
프로그래머스 - 정수를 내림차순으로 배치하기 #include #include #include using namespace std;long long solution(long long n) { string s = to_string(n); sort(s.begin(), s.end(), greater()); return stoll(s);} 더보기
프로그래머스 - 주사위 게임 2 #include #include #include using namespace std;int solution(int a, int b, int c) { int answer = 0; if(a==b or b==c or c==a){ if(a==b and b==c){ answer = (a+b+c)*(pow(a, 2)+pow(b, 2)+pow(c, 2))*(pow(a, 3)+pow(b, 3)+pow(c, 3)); } else{ answer = (a+b+c)*(pow(a, 2)+pow(b, 2)+pow(c, 2)); } } else{ answer = a + b + c; } return .. 더보기