#10250번 ACM 호텔 (c++) #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int testcase = 0; cin >> testcase; for(int i=0; i> h >> w >> c; int ans = 0; if(c%h==0) ans+=h*100+c/h; else if(c%h!=0) ans+=c%h*100+c/h+1; cout 🖥️ CS/Baekjoon Algorithms 2020.02.16
#2869번 달팽이는 올라가고 싶다 (c++) #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int a,b,v = 0; // a=낮에 올라가는 높이, b=밤에 미끄러지는 높이, c=정상까지 높이 int ans = 1; //구하려는 정답 cin >> a >> b >> v; int gap = a-b; ans += (v-a)/gap; if((v-a)%gap!=0) ans++; cout 🖥️ CS/Baekjoon Algorithms 2020.02.16
#1193번 분수찾기 (c++) #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int i = 0; int x = 0; int y = 1; // 분기점 숫자 bool check = true; //true는 홀수, false = 짝수 cin >> i; while(x=i) break; y++; } if(y%2==0) check = false; if(check==true) { cout 🖥️ CS/Baekjoon Algorithms 2020.02.13
#2292번 벌집 (c++) int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int num = 0; // 방의 숫자 int ans = 1; //누적되는 6의 배수 int i = 1; // 거쳐가는 방의 방문 수 cin >> num; while(ans 🖥️ CS/Baekjoon Algorithms 2020.02.12
#2839번 설탕 배달 (c++) #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int w = 0; int a,b,i=0; cin >> w; while(a>=0) { a=(w/5)-i; if(a 🖥️ CS/Baekjoon Algorithms 2020.02.12
#1712번 손익분기점 (c++) #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int a,b,c = 0; // a= 고정 비용 , b = 노트북 한 대 생산가격, c = 노트북 가격 cin >> a >> b >> c; if(b>=c) { cout a >> b >> c; int manu = a+b; if(b>=c) { cout =0) { manu+=(b-c); i++; } cout 🖥️ CS/Baekjoon Algorithms 2020.02.12
#1316번 그룹단어체커 (c++) #include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int test = 0; int ans = 0 ; bool check1 = false; bool check2 = false; cin >> test; for(int i=0; i> s; if(s.size() 🖥️ CS/Baekjoon Algorithms 2020.02.11
#1065번 한수 (c++) #include using namespace std; bool check(int a) { if(((a/100)-(a/10)%10)==((a/10)%10-a%10)) return true; else return false; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int ans = 0; int get = 0; cin >> get; bool num[1001]; // 0~1000개 for(int i=0; i 🖥️ CS/Baekjoon Algorithms 2020.02.08
#4673번 셀프넘버 (c++) #include using namespace std; int check(int a) { return a+(a/1000)+(a/100)%10+(a/10)%10+a%10; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); bool list[10000]; // 0 ~ 9999 for(int i=0; i 🖥️ CS/Baekjoon Algorithms 2020.02.08
정렬(1) - 선택 정렬 / 버블 정렬 / 삽입 정렬 기본적으로 세 정렬 모두 2중 for문을 사용하기 때문에 시간 복잡도는 최대 O(n2) 이다. 1. 선택 정렬 (1) 맨 첫 번째 위치에서 시작한다 (ex : a[0]) (2) 자신보다 오른쪽에 있는 원소 들을 하나씩 탐색한다. (3) 그 중 자신보다 작은 원소가 있으면 swap하여 정렬한다. #include using namespace std; int main(void) { int i,j; int arr[5] = {10,2,15,59,28}; for(int i=0; i 🖥️ CS/Data Structure & Algorithm 2020.02.04