Computer Science/Algorithm

Computer Science/Algorithm

[C++] 백준 1065 - 한수

문제https://www.acmicpc.net/problem/1065 1065번: 한수어떤 양의 정수 X의 각 자리가 등차수열을 이룬다면, 그 수를 한수라고 한다. 등차수열은 연속된 두 개의 수의 차이가 일정한 수열을 말한다. N이 주어졌을 때, 1보다 크거나 같고, N보다 작거나www.acmicpc.net 해설1~99까지는 무조건 등차수열이 될 것이다. 비교할 3번째 항이 없기 때문이다. 100 이상은 각 자릿수를 분해하여 계산해 보면 된다. #include using namespace std;int hansu(int x) { int res = 0, th, h, t, n; for (int i = 1; i = 1000) { th = 1; h = int((i - th * 1000) / 100); ..

Computer Science/Algorithm

[Python] 백준 11721 - 열 개씩 끊어 출력하기

문제https://www.acmicpc.net/problem/11721 11721번: 열 개씩 끊어 출력하기첫째 줄에 단어가 주어진다. 단어는 알파벳 소문자와 대문자로만 이루어져 있으며, 길이는 100을 넘지 않는다. 길이가 0인 단어는 주어지지 않는다.www.acmicpc.net 해설 txt = input()for i in range((len(txt) / 10).__ceil__()): print(txt[i * 10 : (i + 1) * 10])

Computer Science/Algorithm

[Python] 백준 28288 - Special Event

문제https://www.acmicpc.net/problem/28288 28288번: Special EventThe first line of input will contain a positive integer $N$, representing the number of people interested in attending your event. The next $N$ lines will each contain one person's availability using one character for each of Day $1$, Day $2$, Day $3$, Daywww.acmicpc.net 해설numpy를 사용 못하니 map을 이용해서 계산해보았다. person = int(input())schedule =..

Computer Science/Algorithm

[C++] 백준 11399 - ATM

문제https://www.acmicpc.net/problem/11399 11399번: ATM첫째 줄에 사람의 수 N(1 ≤ N ≤ 1,000)이 주어진다. 둘째 줄에는 각 사람이 돈을 인출하는데 걸리는 시간 Pi가 주어진다. (1 ≤ Pi ≤ 1,000)www.acmicpc.net 해설입력된 시간을 정렬하여 누적합을 구하면 되는 문제이다. #include#includeusing namespace std;void atm(){ int n; int temp = 0; int res = 0; cin >> n; int* times = new int[n]; for (int i = 0; i > times[i]; } sort(times, times + n); for (int i = 0; i

Computer Science/Algorithm

[Python] 백준 6973 - Dynamic Dictionary Coding

문제https://www.acmicpc.net/problem/6973 6973번: Dynamic Dictionary CodingA common method of data compression, "dictionary coding", is to replace words in a text by numbers indicating their positions in a dictionary. Static dictionary coding, in which the dictionary is known in advance, can be problematic, as it is necessary towww.acmicpc.net 해설처음 입력된 case만큼의 단어 사전을 만드는 문제이다. 각 case는 여러 문장을 입력받고 모든..

alien_coder
'Computer Science/Algorithm' 카테고리의 글 목록