전체 글
-
백준 1978번 : 소수 찾기정수론(Number theory) 2018. 6. 20. 12:07
https://www.acmicpc.net/problem/1978 1. 문제주어진 수 N개 중에서 소수가 몇 개인지 찾아서 출력하는 프로그램을 작성하시오. 2. 알고리즘소수인지 판별 하여 소수인 수를 카운트를 하여 출력 3. 코드 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152#include #include #include #include #include #include #include #include #include #include #include using namespace std; /** @brief - 소수 판별*/int prime(int n){ if (n == 1) { re..
-
백준 10250번 : ACM 호텔구현(Implementation) 2018. 6. 20. 11:56
https://www.acmicpc.net/problem/10250 1. 문제 방 번호는 YXX 나 YYXX 형태인데 여기서 Y 나 YY 는 층 수를 나타내고 XX 는 엘리베이터에서부터 세었을 때의 번호를 나타낸다. 즉, 그림 1 에서 빗금으로 표시한 방은 305 호가 된다. 손님은 엘리베이터를 타고 이동하는 거리는 신경 쓰지 않는다. 다만 걷는 거리가 같을 때에는 아래층의 방을 더 선호한다. 예를 들면 102 호 방보다는 301 호 방을 더 선호하는데, 102 호는 거리 2 만큼 걸어야 하지만 301 호는 거리 1 만큼만 걸으면 되기 때문이다. 같은 이유로 102 호보다 2101 호를 더 선호한다. 여러분이 작성할 프로그램은 초기에 모든 방이 비어있다고 가정하에 이 정책에 따라 N 번째로 도착한 손님에..
-
백준 1011번 : Fly me to the Alpha Centauri구현(Implementation) 2018. 6. 20. 11:01
https://www.acmicpc.net/problem/1011 1. 문제우현이는 어린 시절, 지구 외의 다른 행성에서도 인류들이 살아갈 수 있는 미래가 오리라 믿었다. 그리고 그가 지구라는 세상에 발을 내려 놓은 지 23년이 지난 지금, 세계 최연소 ASNA 우주 비행사가 되어 새로운 세계에 발을 내려 놓는 영광의 순간을 기다리고 있다.그가 탑승하게 될 우주선은 Alpha Centauri라는 새로운 인류의 보금자리를 개척하기 위한 대규모 생활 유지 시스템을 탑재하고 있기 때문에, 그 크기와 질량이 엄청난 이유로 최신기술력을 총 동원하여 개발한 공간이동 장치를 탑재하였다. 하지만 이 공간이동 장치는 이동 거리를 급격하게 늘릴 경우 기계에 심각한 결함이 발생하는 단점이 있어서, 이전 작동시기에 k광년을 ..
-
백준 15837번 : 백준 온라인 저지문자열(String) 2018. 6. 20. 10:26
https://www.acmicpc.net/problem/15857 1. 문제백준 온라인 저지 사용에 대한 문제. 2. 알고리즘각 문제 별 답안을 출력한다. 3. 코드1234567891011121314151617181920212223// input your code here#include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { std::ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; string s = " abbcdddc"; cout
-
Codeforces Round #486 (Div. 3) - B. Substrings Sort문자열(String) 2018. 6. 19. 11:54
https://codeforces.com/contest/988/problem/B 1. 문제B. Substrings Sorttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given nn strings. Each string consists of lowercase English letters. Rearrange (reorder) the given strings in such a way that for every string, all strings that are placed before it are its substrings. String aa is a subs..
-
Codeforces Round #486 (Div. 3) - A. Diverse Team구현(Implementation) 2018. 6. 19. 11:21
http://codeforces.com/contest/988/problem/A 1. 문제A. Diverse Teamtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are nn students in a school class, the rating of the ii-th student on Codehorses is aiai. You have to form a team consisting of kk students (1≤k≤n1≤k≤n) such that the ratings of all team members are distinct. If it is impossibl..
-
Codeforces Round #489 (Div. 2) : A. Nastya and an Array정렬(Sort) 2018. 6. 19. 10:45
http://codeforces.com/contest/992/problem/A 1. 문제A. Nastya and an Arraytime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output Nastya owns too many arrays now, so she wants to delete the least important of them. However, she discovered that this array is magic! Nastya now knows that the array has the following properties: In one second we can add an ..
-
백준 11441번 : 합 구하기다이나믹프로그래밍(DP) 2018. 6. 18. 14:50
https://www.acmicpc.net/problem/11441 1. 문제 N개의 수 A1, A2, ..., AN이 입력으로 주어진다. 총 M개의 구간 i, j가 주어졌을 때, i번째 수부터 j번째 수까지 합을 구하는 프로그램을 작성하시오. 2. 알고리즘 키워드 - 부분 합최초의 입력 받은 배열은 위 처럼 10, 20, 30, 40, 50 으로 이루어 져있는 배열이다. 배열의 부분합을 만들기 위해 0 번째 배열을 추가하고 배열[i-1] + 배열[i] 부분 합을 구한다. 문제 에서 1번과 4번 배열의 합을 구하라고 나와 있다. 1번 부터 N 까지는 모두 계산이 되어 있음으로 위와 같이 답을 도출 할 수 있다. 두번 째 예제에서는 2번 부터 4 까지의 합을 계산 해야 한다.2번 의 부분합은 30 임으로 ..