목록Computer/Coding Test (70)
Machineboy空
https://www.acmicpc.net/problem/9996 9996번: 한국이 그리울 땐 서버에 접속하지 총 N개의 줄에 걸쳐서, 입력으로 주어진 i번째 파일 이름이 패턴과 일치하면 "DA", 일치하지 않으면 "NE"를 출력한다. 참고로, "DA"는 크로아티어어로 "YES"를, "NE"는 "NO"를 의미한다. www.acmicpc.net 문제 요약 접두사, 접미사 확인하여 같은 패턴의 문자열인지 판단 난이도 Silver 3 풀이 '*' 구분 문자 기준 split 입력값과의 비교 REVIEW 1차 시도: 패턴이 3글자로 주어지는 줄 알고 s[0], s[2]와 단순 비교 2차 시도: split이용해 앞, 뒤 비교. ab*ab로 접두사,접미사가 같을 경우를 고려하지 못함. string.find()로..
https://www.acmicpc.net/problem/10808 10808번: 알파벳 개수 단어에 포함되어 있는 a의 개수, b의 개수, …, z의 개수를 공백으로 구분해서 출력한다. www.acmicpc.net 문제 요약 단어에 들어간 알파벳의 개수를 카운팅하여 배열로 출력. 난이도 Bronze 4 https://www.acmicpc.net/problem/1159 1159번: 농구 경기 상근이는 농구의 세계에서 점차 영향력을 넓혀가고 있다. 처음에 그는 농구 경기를 좋아하는 사람이었다. 농구에 대한 열정은 그를 막을 수 없었고, 결국 상근이는 농구장을 청소하는 일을 시작 www.acmicpc.net 문제 요약 앞 글자가 같은 이름 카운팅 난이도 Bronze 2 풀이 char 형과 int형 간의 형변..
https://www.acmicpc.net/problem/2979 2979번: 트럭 주차 첫째 줄에 문제에서 설명한 주차 요금 A, B, C가 주어진다. (1 ≤ C ≤ B ≤ A ≤ 100) 다음 세 개 줄에는 두 정수가 주어진다. 이 정수는 상근이가 가지고 있는 트럭이 주차장에 도착한 시간과 주차장 www.acmicpc.net 문제 요약 트럭 3대가 각 시간 범위를 가지고, 서로 겹치는 구간을 알아내어 가중치를 곱해줘야 한다. 난이도 Bronze 2 풀이 카운팅 배열 시간 범위를 모두 포괄하는 배열을 만들어 두고, 자동차의 개수를 cnt하여 값을 더해주는 방식 즉, 시간 : 배열의 index, 자동차의 대수 : 해당 index의 값 REVIEW 그래프로 표현해보니 시간 마다 자동차의 대수를 카운트해주..
https://www.acmicpc.net/problem/2309 2309번: 일곱 난쟁이 아홉 개의 줄에 걸쳐 난쟁이들의 키가 주어진다. 주어지는 키는 100을 넘지 않는 자연수이며, 아홉 난쟁이의 키는 모두 다르며, 가능한 정답이 여러 가지인 경우에는 아무거나 출력한다. www.acmicpc.net 문제 요약 9명의 난쟁이 중 7명의 진짜 난쟁이를 찾아라. 일곱 난쟁이의 키의 합은 100. 난이도 Bronze 1 풀이 9명의 순열(permutation)을 구해 가며 7번째까지의 합이 100인지 체크 do-while문, next_permutation 활용 재귀함수로 순열 구현 9명 중 가짜 2명 뽑기 조합(combination) 중첩 for문으로 구현 REVIEW 2번 풀이로 구현했다. 가장 직관적인 ..
매번 티어 랭킹이 궁금해서 찾아보게 됌. Bronze(5~1)
#2745 진법 변환 N진법을 10진법으로 변환 *stoi : string to int 보통 첫번째 파라미터만 넣고 사용해서 원리를 몰랐는데, 디폴트인 10진법으로 알아서 변환해 주는 것이었다. stoi(string,int ,int ) 첫번째 파라미터: 변환해줄 문자열 두번째 파라미터: 실패 시 반환할 값 세번째 파라미터: 변환해줄 진법의 기수 #import using namespace std; string a; int b; int main() { cin >> a >> b; cout > int 로 형변환 // 10 = A, 11 = B ... 매핑해주는 식 // K = 'A' + k -10;A로 부터 몇 칸 떨어진 알파벳이니 My 풀이) 1) B으로 나눈 나머지를 빈 문자열에 + 2) N을 N을 B로 나..
#1152 단어의 개수 while(cin>>s) n++;//입력값이 없을 때까지 반복 아직 printf나 scanf를 잘 활용하지 못하겠다. cin >> A >> B >> C 공백 기준 getline(cin,t) '\n' 기준 #2908 문자열 뒤집기 string a; int b; b = stoi(a);//문자열 숫자로 받기 stoi(string); : 문자열 아스키 코드아닌 숫자로 변환 #5622 다이얼 My 풀이) 번호마다 할당된 문자의 개수가 일정하지 않아서 개수 누적한 배열 만든 후, 어디에 위치할지 선택정렬로 비교하며 위치를 찾았다. 남의 풀이) 할당된 문자의 마지막 문자와 입력 문자의 대소 비교 통해 위치 찾아냄 #import char a; int b; main() { while (std::c..
Mine) using System; public class Solution { public string solution(string my_string) { string answer = ""; answer = my_string.Replace("a",""); answer = answer.Replace("e",""); answer = answer.Replace("i",""); answer = answer.Replace("o",""); answer = answer.Replace("u",""); return answer; } } 다른 사람 풀이) using System; using System.Text.RegularExpressions; //01. foreach문 사용 public class Solution { ..