목록수학 (58)
넘치게 채우기
https://www.acmicpc.net/problem/14916BOJ - 거스름돈문제 유형: 수학, 다이나믹 프로그래밍, 브루트 포스, 그리디, 조건 분기문제 난이도: Silver V시간 제한: 2초메모리 제한: 512MB 문제춘향이는 편의점 카운터에서 일한다.손님이 2원짜리와 5원짜리로만 거스름돈을 달라고 한다. 2원짜리 동전과 5원짜리 동전은 무한정 많이 가지고 있다. 동전의 개수가 최소가 되도록 거슬러 주어야 한다. 거스름돈이 n인 경우, 최소 동전의 개수가 몇 개인지 알려주는 프로그램을 작성하시오.예를 들어, 거스름돈이 15원이면 5원짜리 3개를, 거스름돈이 14원이면 5원짜리 2개와 2원짜리 2개로 총 4개를, 거스름돈이 13원이면 5원짜리 1개와 2원짜리 4개로 총 5개를 주어야 동전의 개..
https://www.acmicpc.net/problem/12755BOJ - 수면 장애문제 유형: 수학, 브루트 포스, 구현문제 난이도: Silver IV시간 제한: 1초메모리 제한: 128MB 문제수면 장애를 가진 강민이는 잠이 오지 않아 적잖은 고통을 느끼고 있다. 강민이는 잠이 오지 않을 때마다 속으로 양을 세고 있었는데, 오늘따라 백만 마리까지 세었는데도 잠이 오지 않았다.한계를 느낀 강민이는 새로운 방법으로 수를 세기로 했다.1부터 숫자를 쭉 이어 붙이면 다음과 같은 숫자열이 생성된다.12345678910111213...강민이는 이 숫자열을 한 숫자씩 떼어서 읽기 시작했다. 수면에 성공한 강민이는 다음날 일어나자마자 "N번째 숫자까지 읽었어!" 라고 기분 좋게 외쳤다.과연 N번째 숫자는 무엇일까..
https://www.acmicpc.net/problem/13021BOJ - 13021 - 공 색칠하기문제 유형: 애드 혹, 수학, 조합론문제 난이도: Silver I시간 제한: 1초메모리 제한: 512MB 문제공 N개가 한 줄로 놓여져 있다. 공은 검정색 또는 흰색으로 칠할 수 있으며, 처음에 모든 공의 색은 흰색이다. 공은 가장 왼쪽이 1번이고, 순서대로 번호가 매겨져 있다.오늘은 공을 칠해보려고 한다. 공은 기계를 이용해서 칠할 수 있는데, 기계는 두 정수 L과 R을 입력으로 받는다. 기계는 L번째 공부터 R번째 공까지를 흰색이나 검정색으로 모두 칠한다.기계를 총 M번 사용했고, 이때 입력한 L과 R을 모두 알고있다. 하지만, 어떤 색으로 칠했는지는 까먹고 말았다. 기계를 모두 M번 사용했을 때, ..
https://leetcode.com/problems/the-k-th-lexicographical-string-of-all-happy-strings-of-length-n/description/leetcode - The k-th Lexicographical String of All Happy Strings of Length n문제 유형: 백트래킹, 수학, 조합론, 해 구성하기문제 난이도: Medium 문제A happy string is a string that:consists only of letters of the set ['a', 'b', 'c'].s[i] != s[i + 1] for all values of i from 1 to s.length - 1 (string is 1-indexed).For e..

https://www.acmicpc.net/problem/1300BOJ - K번째 수문제 유형: 매개변수 탐색(parametric search), 이진 탐색, 행렬문제 난이도: Gold I시간 제한: 2초메모리 제한: 128MB 문제세준이는 크기가 N×N인 배열 A를 만들었다. 배열에 들어있는 수 A[i][j] = i×j 이다. 이 수를 일차원 배열 B에 넣으면 B의 크기는 N×N이 된다. B를 오름차순 정렬했을 때, B[k]를 구해보자.배열 A와 B의 인덱스는 1부터 시작한다. 입력첫째 줄에 배열의 크기 N이 주어진다. N은 105보다 작거나 같은 자연수이다. 둘째 줄에 k가 주어진다. k는 min(109, N2)보다 작거나 같은 자연수이다. 출력B[k]를 출력한다. 풀이n이 정해져 있고 2D배열 A에..
https://codeforces.com/contest/2067/problem/CCodeforces Round 1004(Div.2) - C. Devyatkino문제 유형: 수학, 그리디, 탐색, 브루트 포스시간 제한: 2초메모리 제한: 256MB 문제You are given a positive integer n">n. In one operation, you can add to n">n any positive integer whose decimal representation contains only the digit 9">9, possibly repeated several times.What is the minimum number of operations needed to make the number n"..

https://www.acmicpc.net/problem/25279BOJ - Treehouse문제 유형: 기하학, 수학, 해시문제 난이도: Gold III시간 제한: 3초메모리 제한: 1024MB 문제Pusheen wants to build a treehouse in the Treehouse forest in Brunnshög in the north of Lund. The treehouse should to be built on a square platform in the treetops, with a tree in each of the four corners. When Pusheen has picked a spot to built the treehouse, trees that are located be..
https://codeforces.com/contest/2067/problem/ACodeforces Round 1004(Div.2) - A. Adjacent Digit Sums문제 유형: 수학시간 제한: 1초메모리 제한: 256MB 문제You are given two numbers x,y">x,y. You need to determine if there exists an integer n">n such that S(n)=x">S(n)=x, S(n+1)=y">S(n+1)=y.Here, S(a)">S(a) denotes the sum of the digits of the number a">a in the decimal numeral system. 두 정수 x, y를 받습니다. 당신은 S(n) = x, S(n..
https://leetcode.com/problems/count-number-of-bad-pairs/description/leetcode - Count Number of Bad Pairs문제 유형: 투 포인터, 해시, 정렬, 수학문제 난이도: Medium 문제You are given a 0-indexed integer array nums. A pair of indices (i, j) is a bad pair if i and j - i != nums[j] - nums[i].Return the total number of bad pairs in nums. 0-indexed의 정수 배열 nums가 주어진다.(i, j)페어는 다음 조건을 만족하면 나쁜 페어이다: if i 나쁜 페어의 개수를 구하시오. 풀이전체..
https://leetcode.com/problems/tuple-with-same-product/description/leetcode - Tuple with Same Product문제 유형: 수학, 해시문제 난이도: Medium 문제Given an array nums of distinct positive integers, return the number of tuples (a, b, c, d) such that a * b = c * d where a, b, c, and d are elements of nums, and a != b != c != d. 독립적인 정수 배열 nums가 주어집니다.a*b = c*d인 (a, b, c, d)튜플조합의 개수를 모두 구하시오. 풀이하나의 조합을 구하면, 8개의 튜플을..