Algorithm/PS

Algorithm/PS

[프로그래머스] 개인정보 수집 유효기간 [python]

문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제 풀이 이 문제는 주어진 문자열을 날짜부분과 개인정보 부분으로 적절하게 나누면서, 두 날짜를 비교해야하는 문제이다. 이 문제를 풀기 위해서는 먼저 split() 함수를 통해 문자열을 적절하게 분리해주어야 한다. today : split('.')을 통해 연, 월, 일로 분리 가능 terms : split(' ')을 통해 개인정보와 유효기간으로 분리 가능 privacies : split(' ')과 split('.')을 통해 연, 월, 일과 개인정보로 분리 가능 이를 통해 terms와 privacie..

Algorithm/PS

[BOJ/백준] 26546 - Reverse [python]

문제 링크 26546번: Reverse The first line will contain a single integer n that indicates the number of data sets that follow. Each data set will be one line with a string and two integers i and j, separated by spaces. The first int, i, is the start index of the substring to be taken www.acmicpc.net 문제 풀이 문자열 중, 입력값으로 주어진 i와 j사이의 인덱스는 출력하지 않는 문제이다. 따라서, 문자열 인덱스 0부터 i까지, j부터 문자열의 끝까지 출력할 수 있도록 코드를 작성했다..

Algorithm/PS

[BOJ/백준] 26532 - Acres [python]

문제 링크 26532번: Acres You have a rectangular field you want to plant with corn. You know the dimensions of the field in yards, and you know that one bag of corn seed will cover 5 acres. Having passed all your elementary math courses you also know that 4840 square yards is equal www.acmicpc.net 문제 풀이 단순한 사칙연산 문제이다. 입력값이 야드 단위로 주어지고, 야드와 에이커의 너비는 4840 : 1이다. 5에이커 당 옥수수 종자 한 봉지를 쓸 수 있다고 하니, 9에이커일 경우,..

Algorithm/PS

[BOJ/백준] 26531 - Simple Sum [python]

문제 링크 26531번: Simple Sum You have hired someone to help you with inventory on the farm. Unfortunately, the new cowhand has very limited math skills, and they are having trouble summing two numbers. Write a program to determine if the cowhand is adding these numbers correctly. www.acmicpc.net 문제 풀이 간단한 문제이다. a, b의 합이 c와 같으면 "YES", 다르면 "NO"를 출력해준다. 정답 코드 a, _, b, _, c = input().split() if int(a) +..

Algorithm/PS

[BOJ/백준] 13116 - 30번 [C++/python]

문제 링크 13116번: 30번 첫 번째 줄에 테스트 케이스의 수 T (1 ≤ T ≤ 50 000)가 주어진다. 이후 T개의 테스트 케이스가 주어진다. 각 테스트 케이스는 한 줄로 구성되어 있으며, 각 줄에는 두 개의 정수 A와 B (1 ≤ A, B ≤ 1 www.acmicpc.net 문제 풀이 이 문제는 두 수 a, b의 공통 부모 중 최댓값을 찾는 문제이다. 이 문제의 경우 최댓값을 다음과 같이 찾을 수 있었다. a, b를 각각 33, 79라고 한다면 두 수의 부모 배열은 각각의 수를 2로 나눠가면서 구할 수 있다. 33 : [16, 8, 4, 2, 1] 79 : [39, 19, 9, 4, 2, 1] 두 부모의 배열을 구했다면, 두 수의 공통된 최대 부모 값이 4임을 알 수 있다. 정답 코드 C++ ..

Algorithm/PS

[BOJ/백준] 7595 - Triangles [C++/python]

문제 링크 7595번: Triangles Each line of input contains a single positive integer, n, 1 n; if (n == 0) break; for (int i = 1; i < n + 1; i++) { for (int j = 0; j < i; j++) { cout

Algorithm/PS

[BOJ/백준] 6888 - Terms of Office [C++/python]

문제 링크 6888번: Terms of Office In CS City, a mathematical place to live, the mayor is elected every 4 years, the treasurer is appointed every 2 years, the chief programmer is elected every 3 years and the dog-catcher is replaced every 5 years. This year, Year $X$, the newly elected mayo www.acmicpc.net 문제 풀이 문제 중 "the mayor is elected every 4 years, the treasurer is appointed every 2 years, the ch..

Algorithm/PS

[BOJ/백준] 6887 - Squares [C++/python]

문제 링크 6887번: Squares Gigi likes to play with squares. She has a collection of equal-sized square tiles. Gigi wants to arrange some or all of her tiles on a table to form a solid square. What is the side length of the largest possible square that Gigi can build? For example, wh www.acmicpc.net 문제 풀이 입력값 n보다 낮은 넓이의 정사각형 중, 정사각형 한 변의 최대 길이를 구해야한다. 반복문을 통해 1^2

chanwoong1
'Algorithm/PS' 카테고리의 글 목록 (15 Page)